[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

@@ -62,6 +62,28 @@ TEST(ActorRef, Ask) {
EXPECT_EQ(30, ref.ask(&Test::echo, 30).get());
}
TEST(ActorRef, 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);
ActorRef<Test> ref = actor.self();
ref.ask(&Test::doIt).get();
EXPECT_TRUE(executed);
}
TEST(ActorRef, AskOnDestroyedActor) {
// Tests behavior when calling ask() after the