pub struct Supervisor(pub(crate) Arc<Inner>);Expand description
The process’s supervisor. Cheap to clone; every clone reaches the same registry.
Tuple Fields§
§0: Arc<Inner>Implementations§
Source§impl Supervisor
impl Supervisor
Sourcepub fn new() -> Self
pub fn new() -> Self
Build the registry and start its driver on the current runtime.
A caller with no runtime gets a registry whose driver starts on the
first Self::spawn inside one, so construction never needs a
runtime of its own.
Sourcepub fn spawn<F, Fut>(&self, name: &str, policy: Policy, factory: F) -> bool
pub fn spawn<F, Fut>(&self, name: &str, policy: Policy, factory: F) -> bool
Register name and start its first run.
Returns true when this call started the member and false when it
was already running, so a caller that must know whether its factory
was adopted can read the answer. A second call while the member runs
is a no-op, which is what replaces each member’s own idempotency flag.
A call after a stop or a give-up starts a new run and resets the
counter.
Sourcepub fn stop(&self, name: &str)
pub fn stop(&self, name: &str)
Stop name deliberately: cancel its run, abort it, and never
resurrect it.
The stop names the generation it took down, so a run replaced by a
fresh spawn in the same window is left alone.