Commit a83e4230 authored by Dominik Charousset's avatar Dominik Charousset

Integrate review feedback

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