[core] Actor/ActorRef - ask calls to void methods

- allows to wait for execution of void methods as well as non-void methods
This commit is contained in:
Ivo van Dongen
2017-09-18 13:39:47 +03:00
committed by Ivo van Dongen
parent c17be060fd
commit 8b9794b1a7
3 changed files with 70 additions and 0 deletions

View File

@@ -306,6 +306,28 @@ TEST(Actor, Ask) {
ASSERT_EQ(2, result.get());
}
TEST(Actor, AskVoid) {
// Ask waits for void methods
struct Test {
bool& executed;
Test(bool& executed_) : executed(executed_) {
}
void doIt() {
executed = true;
}
};
ThreadPool pool { 1 };
bool executed = false;
Actor<Test> actor(pool, executed);
actor.ask(&Test::doIt).get();
EXPECT_TRUE(executed);
}
TEST(Actor, NoSelfActorRef) {
// Not all actors need a reference to self