Commit c5f6c835 authored by Dominik Charousset's avatar Dominik Charousset

Merge branch 'issue/1097'

Closes #1097
parents e3f7e64c 9bc0b035
......@@ -711,7 +711,8 @@ template <class T, class Arg>
struct can_apply {
template <class U>
static auto sfinae(U* x)
-> decltype(x->apply(std::declval<Arg>()), std::true_type{});
-> decltype(CAF_IGNORE_UNUSED(x->apply(std::declval<Arg>())),
std::true_type{});
template <class U>
static auto sfinae(...) -> std::false_type;
......
......@@ -33,7 +33,7 @@ namespace caf {
template <class> class behavior_type_of;
template <class> class dictionary;
template <class> class downstream;
template <class> class error_code;
template <class> class [[nodiscard]] error_code;
template <class> class expected;
template <class> class intrusive_cow_ptr;
template <class> class intrusive_ptr;
......@@ -106,7 +106,7 @@ class config_value;
class deserializer;
class downstream_manager;
class downstream_manager_base;
class error;
class [[nodiscard]] error;
class event_based_actor;
class execution_unit;
class forwarding_actor_proxy;
......
......@@ -142,34 +142,34 @@ void binary_serializer::apply(long double x) {
}
void binary_serializer::apply(string_view x) {
begin_sequence(x.size());
CAF_IGNORE_UNUSED(begin_sequence(x.size()));
apply(as_bytes(make_span(x)));
end_sequence();
CAF_IGNORE_UNUSED(end_sequence());
}
void binary_serializer::apply(const std::u16string& x) {
auto str_size = x.size();
begin_sequence(str_size);
CAF_IGNORE_UNUSED(begin_sequence(str_size));
// The standard does not guarantee that char16_t is exactly 16 bits.
for (auto c : x)
apply_int(*this, static_cast<uint16_t>(c));
end_sequence();
CAF_IGNORE_UNUSED(end_sequence());
}
void binary_serializer::apply(const std::u32string& x) {
auto str_size = x.size();
begin_sequence(str_size);
CAF_IGNORE_UNUSED(begin_sequence(str_size));
// The standard does not guarantee that char32_t is exactly 32 bits.
for (auto c : x)
apply_int(*this, static_cast<uint32_t>(c));
end_sequence();
CAF_IGNORE_UNUSED(end_sequence());
}
void binary_serializer::apply(const std::vector<bool>& x) {
auto len = x.size();
begin_sequence(len);
CAF_IGNORE_UNUSED(begin_sequence(len));
if (len == 0) {
end_sequence();
CAF_IGNORE_UNUSED(end_sequence());
return;
}
size_t pos = 0;
......@@ -231,7 +231,7 @@ void binary_serializer::apply(const std::vector<bool>& x) {
}
apply(tmp);
}
end_sequence();
CAF_IGNORE_UNUSED(end_sequence());
}
} // namespace caf
......@@ -119,19 +119,19 @@ error serialized_size_inspector::apply(long double x) {
}
error serialized_size_inspector::apply(string_view x) {
begin_sequence(x.size());
CAF_IGNORE_UNUSED(begin_sequence(x.size()));
result_ += x.size();
return end_sequence();
}
error serialized_size_inspector::apply(const std::u16string& x) {
begin_sequence(x.size());
CAF_IGNORE_UNUSED(begin_sequence(x.size()));
result_ += x.size() * sizeof(uint16_t);
return end_sequence();
}
error serialized_size_inspector::apply(const std::u32string& x) {
begin_sequence(x.size());
CAF_IGNORE_UNUSED(begin_sequence(x.size()));
result_ += x.size() * sizeof(uint32_t);
return end_sequence();
}
......@@ -142,7 +142,7 @@ error serialized_size_inspector::apply(span<const byte> x) {
}
error serialized_size_inspector::apply(const std::vector<bool>& xs) {
begin_sequence(xs.size());
CAF_IGNORE_UNUSED(begin_sequence(xs.size()));
result_ += (xs.size() + static_cast<size_t>(xs.size() % 8 != 0)) / 8;
return end_sequence();
}
......
......@@ -67,12 +67,12 @@ CAF_TEST(meta objects allow serialization of objects) {
binary_serializer sink{nullptr, buf};
meta_i32_wrapper.default_construct(&storage);
CAF_CHECK_EQUAL(i32_wrapper::instances, 1u);
meta_i32_wrapper.save_binary(sink, &storage);
CAF_CHECK_EQUAL(meta_i32_wrapper.save_binary(sink, &storage), none);
i32_wrapper copy;
CAF_CHECK_EQUAL(i32_wrapper::instances, 2u);
copy.value = 42;
binary_deserializer source{nullptr, buf};
meta_i32_wrapper.load_binary(source, &copy);
CAF_CHECK_EQUAL(meta_i32_wrapper.load_binary(source, &copy), none);
CAF_CHECK_EQUAL(copy.value, 0);
meta_i32_wrapper.destroy(&storage);
CAF_CHECK_EQUAL(i32_wrapper::instances, 1u);
......
......@@ -309,12 +309,12 @@ CAF_TEST(long_sequences) {
byte_buffer data;
binary_serializer sink{nullptr, data};
size_t n = std::numeric_limits<uint32_t>::max();
sink.begin_sequence(n);
sink.end_sequence();
CAF_CHECK_EQUAL(sink.begin_sequence(n), none);
CAF_CHECK_EQUAL(sink.end_sequence(), none);
binary_deserializer source{nullptr, data};
size_t m = 0;
source.begin_sequence(m);
source.end_sequence();
CAF_CHECK_EQUAL(source.begin_sequence(m), none);
CAF_CHECK_EQUAL(source.end_sequence(), none);
CAF_CHECK_EQUAL(n, m);
}
......
......@@ -111,7 +111,7 @@ public:
/// Describes a callback function object for `remove_published_actor`.
using removed_published_actor
= callback<error_code<sec>(const strong_actor_ptr&, uint16_t)>;
= callback<void(const strong_actor_ptr&, uint16_t)>;
instance(abstract_broker* parent, callee& lstnr);
......
......@@ -349,7 +349,6 @@ behavior basp_broker::make_behavior() {
CAF_LOG_TRACE(CAF_ARG(whom) << CAF_ARG(port));
auto cb = make_callback([&](const strong_actor_ptr&, uint16_t x) {
close(hdl_by_port(x));
return error_code<sec>{};
});
if (instance.remove_published_actor(whom, port, &cb) == 0)
return sec::no_actor_published_at_port;
......
......@@ -54,7 +54,6 @@ public:
config() {
load<io::middleman>();
load<openssl::manager>();
actor_system_config::parse(test::engine::argc(), test::engine::argv());
set("middleman.manual-multiplexing", true);
set("middleman.attach-utility-actors", true);
set("scheduler.policy", "testing");
......
......@@ -41,7 +41,6 @@ public:
config() {
load<io::middleman>();
load<openssl::manager>();
actor_system_config::parse(test::engine::argc(), test::engine::argv());
// Setting the "max consecutive reads" to 1 is highly likely to cause
// OpenSSL to buffer data internally and report "pending" data after a read
// operation. This will trigger `must_read_more` in the SSL read policy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment