Unverified Commit 41df839f authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #930

Use fold expression in the data_processor if available
parents d6ebaac3 193c39fb
...@@ -475,6 +475,43 @@ public: ...@@ -475,6 +475,43 @@ public:
return none; return none;
} }
#if defined(__cpp_fold_expressions) && defined(__cpp_if_constexpr)
template <class... Ts>
error operator()(Ts&&... xs) {
error result;
auto f = [&result, this](auto&& x) {
using type = detail::decay_t<decltype(x)>;
if constexpr (meta::is_save_callback<type>::value) {
if constexpr (Derived::reads_state)
if (auto err = x.fun()) {
result = std::move(err);
return false;
}
} else if constexpr (meta::is_load_callback<type>::value) {
if constexpr (Derived::writes_state)
if (auto err = x.fun()) {
result = std::move(err);
return false;
}
} else if constexpr (meta::is_annotation<type>::value
|| is_allowed_unsafe_message_type<type>::value) {
// skip element
} else {
if (auto err = dref().apply(deconst(x))) {
result = std::move(err);
return false;
}
}
return true;
};
if ((f(std::forward<Ts>(xs)) && ...))
return none;
return result;
}
#else // defined(__cpp_fold_expressions) && defined(__cpp_if_constexpr)
template <class F, class... Ts> template <class F, class... Ts>
error operator()(meta::save_callback_t<F> x, Ts&&... xs) { error operator()(meta::save_callback_t<F> x, Ts&&... xs) {
// TODO: use `if constexpr` when switching to C++17. // TODO: use `if constexpr` when switching to C++17.
...@@ -525,6 +562,8 @@ public: ...@@ -525,6 +562,8 @@ public:
return dref()(std::forward<Ts>(xs)...); return dref()(std::forward<Ts>(xs)...);
} }
#endif // defined(__cpp_fold_expressions) && defined(__cpp_if_constexpr)
protected: protected:
virtual error apply_impl(int8_t&) = 0; virtual error apply_impl(int8_t&) = 0;
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#pragma once #pragma once
#include <type_traits>
#include "caf/meta/annotation.hpp" #include "caf/meta/annotation.hpp"
namespace caf { namespace caf {
...@@ -36,6 +38,12 @@ struct load_callback_t : annotation { ...@@ -36,6 +38,12 @@ struct load_callback_t : annotation {
F fun; F fun;
}; };
template <class T>
struct is_load_callback : std::false_type {};
template <class F>
struct is_load_callback<load_callback_t<F>> : std::true_type {};
/// Returns an annotation that allows inspectors to call /// Returns an annotation that allows inspectors to call
/// user-defined code after performing load operations. /// user-defined code after performing load operations.
template <class F> template <class F>
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#pragma once #pragma once
#include <type_traits>
#include "caf/meta/annotation.hpp" #include "caf/meta/annotation.hpp"
namespace caf { namespace caf {
...@@ -36,6 +38,12 @@ struct save_callback_t : annotation { ...@@ -36,6 +38,12 @@ struct save_callback_t : annotation {
F fun; F fun;
}; };
template <class T>
struct is_save_callback : std::false_type {};
template <class F>
struct is_save_callback<save_callback_t<F>> : std::true_type {};
/// Returns an annotation that allows inspectors to call /// Returns an annotation that allows inspectors to call
/// user-defined code after performing save operations. /// user-defined code after performing save operations.
template <class F> template <class F>
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "caf/optional.hpp" #include "caf/optional.hpp"
using namespace std;
using namespace caf; using namespace caf;
namespace { namespace {
......
...@@ -21,17 +21,18 @@ ...@@ -21,17 +21,18 @@
// exclude this suite; seems to be too much to swallow for MSVC // exclude this suite; seems to be too much to swallow for MSVC
#ifndef CAF_WINDOWS #ifndef CAF_WINDOWS
#define CAF_SUITE typed_spawn # define CAF_SUITE typed_spawn
#include "caf/test/unit_test.hpp"
#include "caf/string_algorithms.hpp" # include "caf/test/unit_test.hpp"
#include "caf/all.hpp" # include "caf/string_algorithms.hpp"
#define ERROR_HANDLER \ # include "caf/all.hpp"
[&](error& err) { CAF_FAIL(system.render(err)); }
# define ERROR_HANDLER [&](error& err) { CAF_FAIL(system.render(err)); }
using std::string;
using namespace std;
using namespace caf; using namespace caf;
using passed_atom = caf::atom_constant<caf::atom("passed")>; using passed_atom = caf::atom_constant<caf::atom("passed")>;
...@@ -39,7 +40,7 @@ using passed_atom = caf::atom_constant<caf::atom("passed")>; ...@@ -39,7 +40,7 @@ using passed_atom = caf::atom_constant<caf::atom("passed")>;
namespace { namespace {
enum class mock_errc : uint8_t { enum class mock_errc : uint8_t {
cannot_revert_empty = 1 cannot_revert_empty = 1,
}; };
error make_error(mock_errc x) { error make_error(mock_errc x) {
...@@ -55,9 +56,6 @@ using dummy2 = dummy1::extend<reacts_to<ok_atom>>; ...@@ -55,9 +56,6 @@ using dummy2 = dummy1::extend<reacts_to<ok_atom>>;
static_assert(std::is_convertible<dummy2, dummy1>::value, static_assert(std::is_convertible<dummy2, dummy1>::value,
"handle not assignable to narrower definition"); "handle not assignable to narrower definition");
//static_assert(!std::is_convertible<dummy1, dummy2>::value,
// "handle is assignable to broader definition");
using dummy3 = typed_actor<reacts_to<float, int>>; using dummy3 = typed_actor<reacts_to<float, int>>;
using dummy4 = typed_actor<replies_to<int>::with<double>>; using dummy4 = typed_actor<replies_to<int>::with<double>>;
using dummy5 = dummy4::extend_with<dummy3>; using dummy5 = dummy4::extend_with<dummy3>;
...@@ -68,12 +66,6 @@ static_assert(std::is_convertible<dummy5, dummy3>::value, ...@@ -68,12 +66,6 @@ static_assert(std::is_convertible<dummy5, dummy3>::value,
static_assert(std::is_convertible<dummy5, dummy4>::value, static_assert(std::is_convertible<dummy5, dummy4>::value,
"handle not assignable to narrower definition"); "handle not assignable to narrower definition");
//static_assert(!std::is_convertible<dummy3, dummy5>::value,
// "handle is assignable to broader definition");
//static_assert(!std::is_convertible<dummy4, dummy5>::value,
// "handle is assignable to broader definition");
/****************************************************************************** /******************************************************************************
* simple request/response test * * simple request/response test *
******************************************************************************/ ******************************************************************************/
...@@ -92,9 +84,7 @@ using server_type = typed_actor<replies_to<my_request>::with<bool>>; ...@@ -92,9 +84,7 @@ using server_type = typed_actor<replies_to<my_request>::with<bool>>;
server_type::behavior_type typed_server1() { server_type::behavior_type typed_server1() {
return { return {
[](const my_request& req) { [](const my_request& req) { return req.a == req.b; },
return req.a == req.b;
}
}; };
} }
...@@ -114,18 +104,15 @@ public: ...@@ -114,18 +104,15 @@ public:
} }
}; };
void client(event_based_actor* self, const actor& parent, const server_type& serv) { void client(event_based_actor* self, const actor& parent,
self->request(serv, infinite, my_request{0, 0}).then( const server_type& serv) {
[=](bool val1) { self->request(serv, infinite, my_request{0, 0}).then([=](bool val1) {
CAF_CHECK_EQUAL(val1, true); CAF_CHECK_EQUAL(val1, true);
self->request(serv, infinite, my_request{10, 20}).then( self->request(serv, infinite, my_request{10, 20}).then([=](bool val2) {
[=](bool val2) {
CAF_CHECK_EQUAL(val2, false); CAF_CHECK_EQUAL(val2, false);
self->send(parent, passed_atom::value); self->send(parent, passed_atom::value);
} });
); });
}
);
} }
/****************************************************************************** /******************************************************************************
...@@ -134,10 +121,9 @@ void client(event_based_actor* self, const actor& parent, const server_type& ser ...@@ -134,10 +121,9 @@ void client(event_based_actor* self, const actor& parent, const server_type& ser
struct get_state_msg {}; struct get_state_msg {};
using event_testee_type = typed_actor<replies_to<get_state_msg>::with<string>, using event_testee_type = typed_actor<
replies_to<string>::with<void>, replies_to<get_state_msg>::with<string>, replies_to<string>::with<void>,
replies_to<float>::with<void>, replies_to<float>::with<void>, replies_to<int>::with<int>>;
replies_to<int>::with<int>>;
class event_testee : public event_testee_type::base { class event_testee : public event_testee_type::base {
public: public:
...@@ -147,53 +133,31 @@ public: ...@@ -147,53 +133,31 @@ public:
behavior_type wait4string() { behavior_type wait4string() {
return { return {
[](const get_state_msg&) { [=](const get_state_msg&) { return "wait4string"; },
return "wait4string"; [=](const string&) { become(wait4int()); },
}, [=](float) { return skip(); },
[=](const string&) { [=](int) { return skip(); },
become(wait4int());
},
[](float) {
return skip();
},
[](int) {
return skip();
}
}; };
} }
behavior_type wait4int() { behavior_type wait4int() {
return { return {
[](const get_state_msg&) { [=](const get_state_msg&) { return "wait4int"; },
return "wait4int";
},
[=](int) -> int { [=](int) -> int {
become(wait4float()); become(wait4float());
return 42; return 42;
}, },
[](float) { [=](float) { return skip(); },
return skip(); [=](const string&) { return skip(); },
},
[](const string&) {
return skip();
}
}; };
} }
behavior_type wait4float() { behavior_type wait4float() {
return { return {
[](const get_state_msg&) { [=](const get_state_msg&) { return "wait4float"; },
return "wait4float"; [=](float) { become(wait4string()); },
}, [=](const string&) { return skip(); },
[=](float) { [=](int) { return skip(); },
become(wait4string());
},
[](const string&) {
return skip();
},
[](int) {
return skip();
}
}; };
} }
...@@ -213,7 +177,7 @@ string_actor::behavior_type string_reverter() { ...@@ -213,7 +177,7 @@ string_actor::behavior_type string_reverter() {
[](string& str) -> string { [](string& str) -> string {
std::reverse(str.begin(), str.end()); std::reverse(str.begin(), str.end());
return std::move(str); return std::move(str);
} },
}; };
} }
...@@ -225,12 +189,12 @@ string_actor::behavior_type string_delegator(string_actor::pointer self, ...@@ -225,12 +189,12 @@ string_actor::behavior_type string_delegator(string_actor::pointer self,
return { return {
[=](string& str) -> delegated<string> { [=](string& str) -> delegated<string> {
return self->delegate(next, std::move(str)); return self->delegate(next, std::move(str));
} },
}; };
} }
using maybe_string_actor = typed_actor<replies_to<string> using maybe_string_actor = typed_actor<
::with<ok_atom, string>>; replies_to<string>::with<ok_atom, string>>;
maybe_string_actor::behavior_type maybe_string_reverter() { maybe_string_actor::behavior_type maybe_string_reverter() {
return { return {
...@@ -239,17 +203,18 @@ maybe_string_actor::behavior_type maybe_string_reverter() { ...@@ -239,17 +203,18 @@ maybe_string_actor::behavior_type maybe_string_reverter() {
return mock_errc::cannot_revert_empty; return mock_errc::cannot_revert_empty;
std::reverse(str.begin(), str.end()); std::reverse(str.begin(), str.end());
return {ok_atom::value, std::move(str)}; return {ok_atom::value, std::move(str)};
} },
}; };
} }
maybe_string_actor::behavior_type maybe_string_actor::behavior_type
maybe_string_delegator(maybe_string_actor::pointer self, const maybe_string_actor& x) { maybe_string_delegator(maybe_string_actor::pointer self,
const maybe_string_actor& x) {
self->link_to(x); self->link_to(x);
return { return {
[=](string& s) -> delegated<ok_atom, string> { [=](string& s) -> delegated<ok_atom, string> {
return self->delegate(x, std::move(s)); return self->delegate(x, std::move(s));
} },
}; };
} }
...@@ -263,7 +228,7 @@ using float_actor = typed_actor<reacts_to<float>>; ...@@ -263,7 +228,7 @@ using float_actor = typed_actor<reacts_to<float>>;
int_actor::behavior_type int_fun() { int_actor::behavior_type int_fun() {
return { return {
[](int i) { return i * i; } [](int i) { return i * i; },
}; };
} }
...@@ -272,7 +237,7 @@ behavior foo(event_based_actor* self) { ...@@ -272,7 +237,7 @@ behavior foo(event_based_actor* self) {
[=](int i, int_actor server) { [=](int i, int_actor server) {
self->delegate(server, i); self->delegate(server, i);
self->quit(); self->quit();
} },
}; };
} }
...@@ -294,7 +259,7 @@ behavior foo2(event_based_actor* self) { ...@@ -294,7 +259,7 @@ behavior foo2(event_based_actor* self) {
[=](int i, int_actor server) { [=](int i, int_actor server) {
self->delegate(server, i); self->delegate(server, i);
self->quit(); self->quit();
} },
}; };
} }
...@@ -303,7 +268,7 @@ float_actor::behavior_type float_fun(float_actor::pointer self) { ...@@ -303,7 +268,7 @@ float_actor::behavior_type float_fun(float_actor::pointer self) {
[=](float a) { [=](float a) {
CAF_CHECK_EQUAL(a, 1.0f); CAF_CHECK_EQUAL(a, 1.0f);
self->quit(exit_reason::user_shutdown); self->quit(exit_reason::user_shutdown);
} },
}; };
} }
...@@ -311,9 +276,7 @@ int_actor::behavior_type foo3(int_actor::pointer self) { ...@@ -311,9 +276,7 @@ int_actor::behavior_type foo3(int_actor::pointer self) {
auto b = self->spawn<linked>(float_fun); auto b = self->spawn<linked>(float_fun);
self->send(b, 1.0f); self->send(b, 1.0f);
return { return {
[=](int) { [=](int) { return 0; },
return 0;
}
}; };
} }
...@@ -334,39 +297,20 @@ struct fixture { ...@@ -334,39 +297,20 @@ struct fixture {
void test_typed_spawn(server_type ts) { void test_typed_spawn(server_type ts) {
self->send(ts, my_request{1, 2}); self->send(ts, my_request{1, 2});
self->receive( self->receive([](bool value) { CAF_CHECK_EQUAL(value, false); });
[](bool value) {
CAF_CHECK_EQUAL(value, false);
}
);
CAF_MESSAGE("async send + receive"); CAF_MESSAGE("async send + receive");
self->send(ts, my_request{42, 42}); self->send(ts, my_request{42, 42});
self->receive( self->receive([](bool value) { CAF_CHECK_EQUAL(value, true); });
[](bool value) {
CAF_CHECK_EQUAL(value, true);
}
);
CAF_MESSAGE("request + receive with result true"); CAF_MESSAGE("request + receive with result true");
self->request(ts, infinite, my_request{10, 20}).receive( self->request(ts, infinite, my_request{10, 20})
[](bool value) { .receive([](bool value) { CAF_CHECK_EQUAL(value, false); },
CAF_CHECK_EQUAL(value, false); ERROR_HANDLER);
},
ERROR_HANDLER
);
CAF_MESSAGE("request + receive with result false"); CAF_MESSAGE("request + receive with result false");
self->request(ts, infinite, my_request{0, 0}).receive( self->request(ts, infinite, my_request{0, 0})
[](bool value) { .receive([](bool value) { CAF_CHECK_EQUAL(value, true); }, ERROR_HANDLER);
CAF_CHECK_EQUAL(value, true);
},
ERROR_HANDLER
);
CAF_CHECK_EQUAL(system.registry().running(), 2u); CAF_CHECK_EQUAL(system.registry().running(), 2u);
auto c1 = self->spawn(client, self, ts); auto c1 = self->spawn(client, self, ts);
self->receive( self->receive([](passed_atom) { CAF_MESSAGE("received `passed_atom`"); });
[](passed_atom) {
CAF_MESSAGE("received `passed_atom`");
}
);
self->wait_for(c1); self->wait_for(c1);
CAF_CHECK_EQUAL(system.registry().running(), 2u); CAF_CHECK_EQUAL(system.registry().running(), 2u);
} }
...@@ -390,11 +334,7 @@ CAF_TEST(typed_spawns) { ...@@ -390,11 +334,7 @@ CAF_TEST(typed_spawns) {
self->await_all_other_actors_done(); self->await_all_other_actors_done();
CAF_MESSAGE("finished test series with `typed_server2`"); CAF_MESSAGE("finished test series with `typed_server2`");
test_typed_spawn(self->spawn<typed_server3>("hi there", self)); test_typed_spawn(self->spawn<typed_server3>("hi there", self));
self->receive( self->receive([](const string& str) { CAF_REQUIRE_EQUAL(str, "hi there"); });
[](const string& str) {
CAF_REQUIRE_EQUAL(str, "hi there");
}
);
} }
CAF_TEST(event_testee_series) { CAF_TEST(event_testee_series) {
...@@ -419,30 +359,22 @@ CAF_TEST(event_testee_series) { ...@@ -419,30 +359,22 @@ CAF_TEST(event_testee_series) {
// we expect three 42s // we expect three 42s
int i = 0; int i = 0;
self->receive_for(i, 3)([](int value) { CAF_CHECK_EQUAL(value, 42); }); self->receive_for(i, 3)([](int value) { CAF_CHECK_EQUAL(value, 42); });
self->receive( self->receive([&](const string& str) { result = str; },
[&](const string& str) { after(std::chrono::minutes(1)) >>
result = str; [&] { CAF_FAIL("event_testee does not reply"); });
},
after(chrono::minutes(1)) >> [&] {
CAF_FAIL("event_testee does not reply");
}
);
CAF_CHECK_EQUAL(result, "wait4int"); CAF_CHECK_EQUAL(result, "wait4int");
} }
CAF_TEST(string_delegator_chain) { CAF_TEST(string_delegator_chain) {
// run test series with string reverter // run test series with string reverter
auto aut = self->spawn<monitored>(string_delegator, auto aut = self->spawn<monitored>(string_delegator,
system.spawn(string_reverter), system.spawn(string_reverter), true);
true); std::set<string> iface{"caf::replies_to<@str>::with<@str>"};
set<string> iface{"caf::replies_to<@str>::with<@str>"};
CAF_CHECK_EQUAL(aut->message_types(), iface); CAF_CHECK_EQUAL(aut->message_types(), iface);
self->request(aut, infinite, "Hello World!").receive( self->request(aut, infinite, "Hello World!")
[](const string& answer) { .receive([](const string&
CAF_CHECK_EQUAL(answer, "!dlroW olleH"); answer) { CAF_CHECK_EQUAL(answer, "!dlroW olleH"); },
}, ERROR_HANDLER);
ERROR_HANDLER
);
} }
CAF_TEST(maybe_string_delegator_chain) { CAF_TEST(maybe_string_delegator_chain) {
...@@ -450,42 +382,31 @@ CAF_TEST(maybe_string_delegator_chain) { ...@@ -450,42 +382,31 @@ CAF_TEST(maybe_string_delegator_chain) {
auto aut = system.spawn(maybe_string_delegator, auto aut = system.spawn(maybe_string_delegator,
system.spawn(maybe_string_reverter)); system.spawn(maybe_string_reverter));
CAF_MESSAGE("send empty string, expect error"); CAF_MESSAGE("send empty string, expect error");
self->request(aut, infinite, "").receive( self->request(aut, infinite, "")
[](ok_atom, const string&) { .receive([](ok_atom,
CAF_FAIL("unexpected string response"); const string&) { CAF_FAIL("unexpected string response"); },
},
[](const error& err) { [](const error& err) {
CAF_CHECK_EQUAL(err.category(), atom("mock")); CAF_CHECK_EQUAL(err.category(), atom("mock"));
CAF_CHECK_EQUAL(err.code(), CAF_CHECK_EQUAL(err.code(), static_cast<uint8_t>(
static_cast<uint8_t>(mock_errc::cannot_revert_empty)); mock_errc::cannot_revert_empty));
} });
);
CAF_MESSAGE("send abcd string, expect dcba"); CAF_MESSAGE("send abcd string, expect dcba");
self->request(aut, infinite, "abcd").receive( self->request(aut, infinite, "abcd")
[](ok_atom, const string& str) { .receive([](ok_atom, const string& str) { CAF_CHECK_EQUAL(str, "dcba"); },
CAF_CHECK_EQUAL(str, "dcba"); ERROR_HANDLER);
},
ERROR_HANDLER
);
} }
CAF_TEST(sending_typed_actors) { CAF_TEST(sending_typed_actors) {
auto aut = system.spawn(int_fun); auto aut = system.spawn(int_fun);
self->send(self->spawn(foo), 10, aut); self->send(self->spawn(foo), 10, aut);
self->receive( self->receive([](int i) { CAF_CHECK_EQUAL(i, 100); });
[](int i) {
CAF_CHECK_EQUAL(i, 100);
}
);
self->spawn(foo3); self->spawn(foo3);
} }
CAF_TEST(sending_typed_actors_and_down_msg) { CAF_TEST(sending_typed_actors_and_down_msg) {
auto aut = system.spawn(int_fun2); auto aut = system.spawn(int_fun2);
self->send(self->spawn(foo2), 10, aut); self->send(self->spawn(foo2), 10, aut);
self->receive([](int i) { self->receive([](int i) { CAF_CHECK_EQUAL(i, 100); });
CAF_CHECK_EQUAL(i, 100);
});
} }
CAF_TEST(check_signature) { CAF_TEST(check_signature) {
...@@ -494,20 +415,16 @@ CAF_TEST(check_signature) { ...@@ -494,20 +415,16 @@ CAF_TEST(check_signature) {
using bar_type = typed_actor<reacts_to<ok_atom>>; using bar_type = typed_actor<reacts_to<ok_atom>>;
auto foo_action = [](foo_type::pointer ptr) -> foo_type::behavior_type { auto foo_action = [](foo_type::pointer ptr) -> foo_type::behavior_type {
return { return {
[=] (put_atom) -> foo_result_type { [=](put_atom) -> foo_result_type {
ptr->quit(); ptr->quit();
return {ok_atom::value}; return {ok_atom::value};
} },
}; };
}; };
auto bar_action = [=](bar_type::pointer ptr) -> bar_type::behavior_type { auto bar_action = [=](bar_type::pointer ptr) -> bar_type::behavior_type {
auto foo = ptr->spawn<linked>(foo_action); auto foo = ptr->spawn<linked>(foo_action);
ptr->send(foo, put_atom::value); ptr->send(foo, put_atom::value);
return { return {[=](ok_atom) { ptr->quit(); }};
[=](ok_atom) {
ptr->quit();
}
};
}; };
auto x = self->spawn(bar_action); auto x = self->spawn(bar_action);
self->wait_for(x); self->wait_for(x);
......
...@@ -33,6 +33,14 @@ ...@@ -33,6 +33,14 @@
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/io/all.hpp" #include "caf/io/all.hpp"
#include "caf/deep_to_string.hpp"
#include "caf/io/network/interfaces.hpp"
#include "caf/io/network/test_multiplexer.hpp"
using namespace caf;
using namespace caf::io;
namespace { namespace {
using caf::make_message_id; using caf::make_message_id;
...@@ -72,14 +80,6 @@ constexpr auto basp_atom = caf::atom("BASP"); ...@@ -72,14 +80,6 @@ constexpr auto basp_atom = caf::atom("BASP");
constexpr auto spawn_serv_atom = caf::atom("SpawnServ"); constexpr auto spawn_serv_atom = caf::atom("SpawnServ");
constexpr auto config_serv_atom = caf::atom("ConfigServ"); constexpr auto config_serv_atom = caf::atom("ConfigServ");
} // namespace
using namespace std;
using namespace caf;
using namespace caf::io;
namespace {
constexpr uint32_t num_remote_nodes = 2; constexpr uint32_t num_remote_nodes = 2;
using buffer = std::vector<char>; using buffer = std::vector<char>;
...@@ -259,10 +259,9 @@ public: ...@@ -259,10 +259,9 @@ public:
return {hdr, std::move(payload)}; return {hdr, std::move(payload)};
} }
void connect_node( void connect_node(node& n, optional<accept_handle> ax = none,
node& n, optional<accept_handle> ax = none,
actor_id published_actor_id = invalid_actor_id, actor_id published_actor_id = invalid_actor_id,
const set<string>& published_actor_ifs = std::set<std::string>{}) { const std::set<std::string>& published_actor_ifs = {}) {
auto src = ax ? *ax : ahdl_; auto src = ax ? *ax : ahdl_;
CAF_MESSAGE("connect remote node " CAF_MESSAGE("connect remote node "
<< n.name << ", connection ID = " << n.connection.id() << n.name << ", connection ID = " << n.connection.id()
...@@ -412,8 +411,8 @@ private: ...@@ -412,8 +411,8 @@ private:
accept_handle ahdl_; accept_handle ahdl_;
network::test_multiplexer* mpx_; network::test_multiplexer* mpx_;
node_id this_node_; node_id this_node_;
unique_ptr<scoped_actor> self_; std::unique_ptr<scoped_actor> self_;
array<node, num_remote_nodes> nodes_; std::array<node, num_remote_nodes> nodes_;
/* /*
array<node_id, num_remote_nodes> remote_node_; array<node_id, num_remote_nodes> remote_node_;
array<connection_handle, num_remote_nodes> remote_hdl_; array<connection_handle, num_remote_nodes> remote_hdl_;
...@@ -493,7 +492,7 @@ CAF_TEST(non_empty_server_handshake) { ...@@ -493,7 +492,7 @@ CAF_TEST(non_empty_server_handshake) {
buffer expected_payload; buffer expected_payload;
binary_serializer bd{nullptr, expected_payload}; binary_serializer bd{nullptr, expected_payload};
bd(instance().this_node(), defaults::middleman::app_identifiers, self()->id(), bd(instance().this_node(), defaults::middleman::app_identifiers, self()->id(),
set<string>{"caf::replies_to<@u16>::with<@u16>"}); std::set<std::string>{"caf::replies_to<@u16>::with<@u16>"});
CAF_CHECK_EQUAL(hexstr(payload), hexstr(expected_payload)); CAF_CHECK_EQUAL(hexstr(payload), hexstr(expected_payload));
} }
...@@ -633,7 +632,7 @@ CAF_TEST(remote_actor_and_send) { ...@@ -633,7 +632,7 @@ CAF_TEST(remote_actor_and_send) {
{basp::message_type::direct_message, 0, 0, 0, {basp::message_type::direct_message, 0, 0, 0,
jupiter().dummy_actor->id(), self()->id()}, jupiter().dummy_actor->id(), self()->id()},
std::vector<strong_actor_ptr>{}, make_message("hi there!")); std::vector<strong_actor_ptr>{}, make_message("hi there!"));
self()->receive([&](const string& str) { self()->receive([&](const std::string& str) {
CAF_CHECK_EQUAL(to_string(self()->current_sender()), to_string(result)); CAF_CHECK_EQUAL(to_string(self()->current_sender()), to_string(result));
CAF_CHECK_EQUAL(self()->current_sender(), result.address()); CAF_CHECK_EQUAL(self()->current_sender(), result.address());
CAF_CHECK_EQUAL(str, "hi there!"); CAF_CHECK_EQUAL(str, "hi there!");
......
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