From 68f470fdda4e31d7704fba3e41bb2f899db39541 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Tue, 8 Aug 2017 10:42:44 +0300 Subject: [core] make actor self reference optional - again - uses a different method of constructor selection that also works on Apple clang < 8.2. --- test/actor/actor.test.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') diff --git a/test/actor/actor.test.cpp b/test/actor/actor.test.cpp index 2b4c83f566..4c7fc3666d 100644 --- a/test/actor/actor.test.cpp +++ b/test/actor/actor.test.cpp @@ -305,3 +305,34 @@ TEST(Actor, Ask) { ASSERT_EQ(std::future_status::ready, status); ASSERT_EQ(2, result.get()); } + +TEST(Actor, NoSelfActorRef) { + // Not all actors need a reference to self + + // Trivially constructable + struct Trivial {}; + + ThreadPool pool { 2 }; + Actor trivial(pool); + + + // With arguments + struct WithArguments { + std::promise promise; + + WithArguments(std::promise promise_) + : promise(std::move(promise_)) { + } + + void receive() { + promise.set_value(); + } + }; + + std::promise promise; + auto future = promise.get_future(); + Actor withArguments(pool, std::move(promise)); + + withArguments.invoke(&WithArguments::receive); + future.wait(); +} -- cgit v1.2.1