[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:
committed by
Ivo van Dongen
parent
c17be060fd
commit
8b9794b1a7
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user