Commit a83e4230 authored by Dominik Charousset's avatar Dominik Charousset

Integrate review feedback

parent 0777157c
...@@ -31,31 +31,31 @@ ...@@ -31,31 +31,31 @@
namespace caf::detail { namespace caf::detail {
template <class Self, class Sender, class Handle, class... Ts> template <class Self, class SelfHandle, class Handle, class... Ts>
void profiled_send(Self* self, Sender&& sender, const Handle& receiver, void profiled_send(Self* self, SelfHandle&& src, const Handle& dst,
message_id msg_id, std::vector<strong_actor_ptr> stages, message_id msg_id, std::vector<strong_actor_ptr> stages,
execution_unit* context, Ts&&... xs) { execution_unit* context, Ts&&... xs) {
CAF_IGNORE_UNUSED(self); CAF_IGNORE_UNUSED(self);
if (receiver) { if (dst) {
auto element = make_mailbox_element(std::forward<Sender>(sender), msg_id, auto element = make_mailbox_element(std::forward<SelfHandle>(src), msg_id,
std::move(stages), std::move(stages),
std::forward<Ts>(xs)...); std::forward<Ts>(xs)...);
CAF_BEFORE_SENDING(self, *element); CAF_BEFORE_SENDING(self, *element);
receiver->enqueue(std::move(element), context); dst->enqueue(std::move(element), context);
} }
} }
template <class Self, class Sender, class Handle, class... Ts> template <class Self, class SelfHandle, class Handle, class... Ts>
void profiled_send(Self* self, Sender&& sender, const Handle& dst, void profiled_send(Self* self, SelfHandle&& src, const Handle& dst,
actor_clock& clock, actor_clock::time_point timeout, actor_clock& clock, actor_clock::time_point timeout,
message_id msg_id, Ts&&... xs) { message_id msg_id, Ts&&... xs) {
CAF_IGNORE_UNUSED(self); CAF_IGNORE_UNUSED(self);
if (dst) { if (dst) {
if constexpr (std::is_same<Handle, group>::value) { if constexpr (std::is_same<Handle, group>::value) {
clock.schedule_message(timeout, dst, std::forward<Sender>(sender), clock.schedule_message(timeout, dst, std::forward<SelfHandle>(src),
make_message(std::forward<Ts>(xs)...)); make_message(std::forward<Ts>(xs)...));
} else { } else {
auto element = make_mailbox_element(std::forward<Sender>(sender), msg_id, auto element = make_mailbox_element(std::forward<SelfHandle>(src), msg_id,
no_stages, std::forward<Ts>(xs)...); no_stages, std::forward<Ts>(xs)...);
CAF_BEFORE_SENDING_SCHEDULED(self, timeout, *element); CAF_BEFORE_SENDING_SCHEDULED(self, timeout, *element);
clock.schedule_message(timeout, actor_cast<strong_actor_ptr>(dst), clock.schedule_message(timeout, actor_cast<strong_actor_ptr>(dst),
......
...@@ -41,6 +41,8 @@ struct fixture : test_coordinator_fixture<> { ...@@ -41,6 +41,8 @@ struct fixture : test_coordinator_fixture<> {
group grp; group grp;
actor testee; actor testee;
std::string hello = "hello world";
fixture() { fixture() {
grp = sys.groups().anonymous(); grp = sys.groups().anonymous();
testee = sys.spawn_in_group(grp, testee_impl); testee = sys.spawn_in_group(grp, testee_impl);
...@@ -56,49 +58,47 @@ struct fixture : test_coordinator_fixture<> { ...@@ -56,49 +58,47 @@ struct fixture : test_coordinator_fixture<> {
CAF_TEST_FIXTURE_SCOPE(sender_tests, fixture) CAF_TEST_FIXTURE_SCOPE(sender_tests, fixture)
CAF_TEST(delayed actor messages receive responses) { CAF_TEST(delayed actor messages receive responses) {
self->delayed_send(testee, seconds(1), "hello world"); self->delayed_send(testee, seconds(1), hello);
sched.trigger_timeout(); sched.trigger_timeout();
expect((std::string), from(self).to(testee).with("hello world")); expect((std::string), from(self).to(testee).with(hello));
expect((std::string), from(testee).to(self).with("hello world")); expect((std::string), from(testee).to(self).with(hello));
self->scheduled_send(testee, self->clock().now() + seconds(1), "hello world"); self->scheduled_send(testee, self->clock().now() + seconds(1), hello);
sched.trigger_timeout(); sched.trigger_timeout();
expect((std::string), from(self).to(testee).with("hello world")); expect((std::string), from(self).to(testee).with(hello));
expect((std::string), from(testee).to(self).with("hello world")); expect((std::string), from(testee).to(self).with(hello));
} }
CAF_TEST(delayed group message receive responses) { CAF_TEST(delayed group message receive responses) {
self->delayed_send(grp, seconds(1), "hello world"); self->delayed_send(grp, seconds(1), hello);
sched.trigger_timeout(); sched.trigger_timeout();
expect((std::string), from(self).to(testee).with("hello world")); expect((std::string), from(self).to(testee).with(hello));
expect((std::string), from(testee).to(self).with("hello world")); expect((std::string), from(testee).to(self).with(hello));
self->scheduled_send(grp, self->clock().now() + seconds(1), "hello world"); self->scheduled_send(grp, self->clock().now() + seconds(1), hello);
sched.trigger_timeout(); sched.trigger_timeout();
expect((std::string), from(self).to(testee).with("hello world")); expect((std::string), from(self).to(testee).with(hello));
expect((std::string), from(testee).to(self).with("hello world")); expect((std::string), from(testee).to(self).with(hello));
} }
CAF_TEST(anonymous messages receive no response) { CAF_TEST(anonymous messages receive no response) {
self->anon_send(testee, "hello world"); self->anon_send(testee, hello);
expect((std::string), to(testee).with("hello world")); expect((std::string), to(testee).with(hello));
disallow((std::string), from(testee).to(self).with("hello world")); disallow((std::string), from(testee).to(self).with(hello));
self->delayed_anon_send(testee, seconds(1), "hello world"); self->delayed_anon_send(testee, seconds(1), hello);
sched.trigger_timeout(); sched.trigger_timeout();
expect((std::string), to(testee).with("hello world")); expect((std::string), to(testee).with(hello));
disallow((std::string), from(testee).to(self).with("hello world")); disallow((std::string), from(testee).to(self).with(hello));
self->scheduled_anon_send(testee, self->clock().now() + seconds(1), self->scheduled_anon_send(testee, self->clock().now() + seconds(1), hello);
"hello world");
sched.trigger_timeout(); sched.trigger_timeout();
expect((std::string), to(testee).with("hello world")); expect((std::string), to(testee).with(hello));
disallow((std::string), from(testee).to(self).with("hello world")); disallow((std::string), from(testee).to(self).with(hello));
self->delayed_anon_send(grp, seconds(1), "hello world"); self->delayed_anon_send(grp, seconds(1), hello);
sched.trigger_timeout(); sched.trigger_timeout();
expect((std::string), to(testee).with("hello world")); expect((std::string), to(testee).with(hello));
disallow((std::string), from(testee).to(self).with("hello world")); disallow((std::string), from(testee).to(self).with(hello));
self->scheduled_anon_send(grp, self->clock().now() + seconds(1), self->scheduled_anon_send(grp, self->clock().now() + seconds(1), hello);
"hello world");
sched.trigger_timeout(); sched.trigger_timeout();
expect((std::string), to(testee).with("hello world")); expect((std::string), to(testee).with(hello));
disallow((std::string), from(testee).to(self).with("hello world")); disallow((std::string), from(testee).to(self).with(hello));
} }
CAF_TEST_FIXTURE_SCOPE_END() CAF_TEST_FIXTURE_SCOPE_END()
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