Add Activation::stop_root

This commit is contained in:
Tony Garnock-Jones 2022-01-10 11:23:02 +01:00
parent a6ea858f1c
commit 58bde1e29d
2 changed files with 9 additions and 1 deletions

View File

@ -56,7 +56,7 @@ pub fn terminate_on_service_restart<'a, N: Unparse<&'a Language<AnyValue>, AnyVa
) {
on_service_restart(t, ds, service_name, |t| {
tracing::info!("Terminating to restart");
t.state.shutdown();
t.stop_root();
Ok(())
});
}

View File

@ -1118,6 +1118,14 @@ impl<'activation> Activation<'activation> {
self.stop_facet(self.facet.facet_id)
}
/// Arranges for the active actor's root facet to be stopped cleanly when `self` commits;
/// this is one way to arrange a clean shutdown of the entire actor.
///
/// Equivalent to `self.stop_facet(self.state.root)`.
pub fn stop_root(&mut self) {
self.stop_facet(self.state.root);
}
fn stop_if_inert(&mut self) {
let facet_id = self.facet.facet_id;
self.enqueue_for_myself_at_commit(Box::new(move |t| {