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