Commit 216d1fae authored by Dominik Charousset's avatar Dominik Charousset

Reformat test_remote_actor

parent b8b9faae
...@@ -32,76 +32,72 @@ void reflector(event_based_actor* self) { ...@@ -32,76 +32,72 @@ void reflector(event_based_actor* self) {
} }
void spawn5_server_impl(event_based_actor* self, actor client, group grp) { void spawn5_server_impl(event_based_actor* self, actor client, group grp) {
CAF_LOGF_TRACE(CAF_TARG(client, to_string) << ", " CAF_LOGF_TRACE(CAF_TARG(client, to_string)
<< CAF_TARG(grp, to_string)); << ", " << CAF_TARG(grp, to_string));
CAF_CHECK(grp != invalid_group); CAF_CHECK(grp != invalid_group);
self->spawn_in_group(grp, reflector); self->spawn_in_group(grp, reflector);
self->spawn_in_group(grp, reflector); self->spawn_in_group(grp, reflector);
CAF_PRINT("send {'Spawn5'} and await {'ok', actor_vector}"); CAF_PRINT("send {'Spawn5'} and await {'ok', actor_vector}");
self->sync_send(client, atom("Spawn5"), grp) self->sync_send(client, atom("Spawn5"), grp).then(
.then(on(atom("ok"), arg_match) >> [=](const actor_vector& vec) { on(atom("ok"), arg_match) >> [=](const actor_vector& vec) {
CAF_PRINT("received vector with " << vec.size() CAF_PRINT("received vector with " << vec.size() << " elements");
<< " elements"); self->send(grp, "Hello reflectors!", 5.0);
self->send(grp, "Hello reflectors!", 5.0); if (vec.size() != 5) {
if (vec.size() != 5) { CAF_PRINTERR("remote client did not spawn five reflectors!");
CAF_PRINTERR( }
"remote client did not spawn five reflectors!"); for (auto& a : vec) {
} CAF_PRINT("monitor actor: " << to_string(a));
for (auto& a : vec) { self->monitor(a);
CAF_PRINT("monitor actor: " << to_string(a)); }
self->monitor(a); },
} others() >> [=] {
}, CAF_UNEXPECTED_MSG(self);
others() >> [=] { self->quit(exit_reason::user_defined);
CAF_UNEXPECTED_MSG(self); },
self->quit(exit_reason::unhandled_exception); after(chrono::seconds(10)) >> [=] {
}, CAF_UNEXPECTED_TOUT();
after(chrono::seconds(10)) >> [=] { self->quit(exit_reason::user_defined);
CAF_UNEXPECTED_TOUT(); }
self->quit(exit_reason::unhandled_exception); ).continue_with([=] {
}) CAF_PRINT("wait for reflected messages");
.continue_with([=] { // receive seven reply messages (2 local, 5 remote)
CAF_PRINT("wait for reflected messages"); auto replies = std::make_shared<int>(0);
// receive seven reply messages (2 local, 5 remote) self->become(
auto replies = std::make_shared<int>(0); on("Hello reflectors!", 5.0) >> [=] {
self->become( if (++*replies == 7) {
on("Hello reflectors!", 5.0) >> [=] { CAF_PRINT("wait for DOWN messages");
if (++*replies == 7) { auto downs = std::make_shared<int>(0);
CAF_PRINT("wait for DOWN messages"); self->become(
auto downs = std::make_shared<int>(0); [=](const down_msg& dm) {
self->become( if (dm.reason != exit_reason::normal) {
[=](const down_msg& dm) { CAF_PRINTERR("reflector exited for non-normal exit reason!");
if (dm.reason != exit_reason::normal) { }
CAF_PRINTERR( if (++*downs == 5) {
"reflector exited for non-normal exit " CAF_CHECKPOINT();
"reason!"); self->send(client, atom("Spawn5Done"));
} self->quit();
if (++*downs == 5) { }
CAF_CHECKPOINT(); },
self->send(client, atom("Spawn5Done")); others() >> [=] {
self->quit(); CAF_UNEXPECTED_MSG(self);
} self->quit(exit_reason::user_defined);
}, },
others() >> [=] { after(chrono::seconds(2)) >> [=] {
CAF_UNEXPECTED_MSG(self); CAF_UNEXPECTED_TOUT();
// self->quit(exit_reason::unhandled_exception); CAF_LOGF_ERROR("did only receive " << *downs << " down messages");
}, self->quit(exit_reason::user_defined);
after(chrono::seconds(2)) >> [=] { }
CAF_UNEXPECTED_TOUT(); );
CAF_LOGF_ERROR("did only receive " }
<< *downs << " down messages"); },
// self->quit(exit_reason::unhandled_exception); after(std::chrono::seconds(2)) >> [=] {
}); CAF_UNEXPECTED_TOUT();
} CAF_LOGF_ERROR("did only receive " << *replies
}, << " responses to 'Hello reflectors!'");
after(std::chrono::seconds(2)) >> [=] { self->quit(exit_reason::user_defined);
CAF_UNEXPECTED_TOUT(); }
CAF_LOGF_ERROR("did only receive " );
<< *replies });
<< " responses to 'Hello reflectors!'");
// self->quit(exit_reason::unhandled_exception);
});
});
} }
// receive seven reply messages (2 local, 5 remote) // receive seven reply messages (2 local, 5 remote)
......
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