Commit c909132e authored by Dominik Charousset's avatar Dominik Charousset

No longer support canceling quit with on_exit

Closes #280
parent 001cd0c0
......@@ -602,30 +602,23 @@ resumable::resume_result local_actor::resume(execution_unit* eu,
}
// actor is cooperatively scheduled
host(eu);
auto done_cb = [&]() -> bool {
auto done_cb = [&] {
CAF_LOG_TRACE("");
bhvr_stack().clear();
bhvr_stack().cleanup();
on_exit();
CAF_LOG_DEBUG("on_exit did set a new behavior: ignored");
auto rsn = planned_exit_reason();
if (rsn != exit_reason::kill) {
if (has_behavior()) {
CAF_LOG_DEBUG("on_exit did set a new behavior");
planned_exit_reason(exit_reason::not_exited);
return false; // on_exit did set a new behavior
}
if (rsn == exit_reason::not_exited) {
rsn = exit_reason::normal;
planned_exit_reason(rsn);
}
}
cleanup(rsn);
return true;
};
auto actor_done = [&]() -> bool {
if (!has_behavior()
|| planned_exit_reason() != exit_reason::not_exited) {
return done_cb();
if (!has_behavior() || planned_exit_reason() != exit_reason::not_exited) {
done_cb();
return true;
}
return false;
};
......
......@@ -259,6 +259,26 @@ CAF_TEST(test_void_res) {
self->send_exit(buddy, exit_reason::kill);
}
CAF_TEST(pending_quit) {
auto mirror = spawn([](event_based_actor* self) -> behavior {
return {
others >> [=] {
self->quit();
return std::move(self->current_message());
}
};
});
spawn([mirror](event_based_actor* self) {
self->sync_send(mirror, 42).then(
others >> [] {
CAF_TEST_ERROR("received result, should've been terminated already");
}
);
self->quit();
});
await_all_actors_done();
}
CAF_TEST(sync_send) {
scoped_actor self;
self->on_sync_failure([&] {
......
......@@ -61,5 +61,7 @@ class local_actor;
\hline
\lstinline^template <class F>^ \lstinline^void set_exception_handler(F f)^ & Sets a custom handler for uncaught exceptions \\
\hline
\lstinline^void on_exit()^ & Can be overridden to add cleanup code that runs after an actor finished execution, e.g., to break cycles \\
\hline
\end{tabular*}
}
......@@ -195,7 +195,7 @@ This feature has been removed without substitution.
\subsubsection{0.12 $\Rightarrow$ 0.13}
This release removes the (since 0.9 deprecated) \lstinline^cppa^ headers and deprecates all \lstinline^*_send_tuple^ versions (simply use the function without \lstinline^_tuple^ suffix).
This release removes the (since 0.9 deprecated) \lstinline^cppa^ headers and deprecates all \lstinline^*_send_tuple^ versions (simply use the function without \lstinline^_tuple^ suffix). \lstinline^local_actor::on_exit^ once again became virtual.
In case you were using the old \lstinline^cppa::options_description^ API, you can migrate to the new API based on \lstinline^extract^ (cf. \ref{Sec::Messages::ExtractOpts}).
......
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