Permalink
Browse files

let stacked actors execute `become`

  • Loading branch information...
1 parent da5cadb commit f67517fba6a9bff41b9600a6e0172bbd0235f973 @Neverlord Neverlord committed Apr 10, 2013
Showing with 17 additions and 0 deletions.
  1. +2 −0 cppa/stacked.hpp
  2. +15 −0 unit_testing/test_spawn.cpp
View
@@ -117,6 +117,7 @@ class stacked : public Base {
void become_impl(behavior&& bhvr, bool discard_old, message_id mid) {
auto dthis = util::dptr<Subtype>(this);
+ bool exec_afterwards = dthis->m_bhvr_stack.empty();
if (bhvr.timeout().valid()) {
dthis->reset_timeout();
dthis->request_timeout(bhvr.timeout());
@@ -125,6 +126,7 @@ class stacked : public Base {
dthis->m_bhvr_stack.pop_async_back();
}
dthis->m_bhvr_stack.push_back(std::move(bhvr), mid);
+ if (exec_afterwards) dthis->exec_behavior_stack();
}
};
@@ -693,8 +693,23 @@ int main() {
);
// wait for termination of all spawned actors
await_all_others_done();
+ // don't try this at home, kids
+ send(self, atom("check"));
+ try {
+ become (
+ on(atom("check")) >> [] {
+ CPPA_CHECKPOINT();
+ self->quit();
+ }
+ );
+ CPPA_ERROR("line " << __LINE__ << " should be unreachable");
+ }
+ catch (actor_exited&) {
+ CPPA_CHECKPOINT();
+ }
CPPA_CHECK_EQUAL(flags, 0x0F);
// verify pong messages
CPPA_CHECK_EQUAL(pongs(), 10);
+ shutdown();
return CPPA_TEST_RESULT();
}

0 comments on commit f67517f

Please sign in to comment.