Commit 2f9fb78b authored by Dominik Charousset's avatar Dominik Charousset

Allow scoped actors to use `planned_exit_reason`

This patch allows scoped actors to define a desired exit reason using
`planned_exit_reason` to cover use cases as mentioned in #131.
parent cba2a079
......@@ -72,6 +72,8 @@ scoped_actor::scoped_actor(bool hide_actor) {
}
scoped_actor::~scoped_actor() {
auto r = m_self->planned_exit_reason();
m_self->cleanup(r == exit_reason::not_exited ? exit_reason::normal : r);
if (!m_hidden) {
get_actor_registry()->dec_running();
CPPA_SET_AID(m_prev);
......
......@@ -929,6 +929,14 @@ int main() {
CPPA_TEST(test_spawn);
test_spawn();
CPPA_CHECKPOINT();
// test setting exit reasons for scoped actors
{ // lifetime scope of self
scoped_actor self;
self->spawn<linked>([]() -> behavior { return others() >> [] {}; });
self->planned_exit_reason(exit_reason::user_defined);
}
await_all_actors_done();
CPPA_CHECKPOINT();
shutdown();
CPPA_CHECKPOINT();
return CPPA_TEST_RESULT();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment