pub struct Supervisor { /* private fields */ }Expand description
Host-side child restarter (design notes §15-16).
A Supervisor is not a bytecode Flow. It is a dedicated OS
thread plus a table of ChildSpecs. When a supervised flow
becomes FlowOutcome::Failed (or completes, under
RestartPolicy::Always), the worker delivers the
FlowOutcome here instead of letting the fault take anything
else down. The supervisor then consults the child’s
RestartPolicy and, if intensity allows, respawns it under a
fresh FlowId — Pids are never reused (see
super::process::FlowId).
Constructed from a RuntimeSpawner so it does not have to own the
runtime’s worker JoinHandles.
Implementations§
Source§impl Supervisor
impl Supervisor
pub fn new(spawner: RuntimeSpawner) -> Result<Self, SpawnError>
Sourcepub fn with_config(
spawner: RuntimeSpawner,
config: SupervisorConfig,
) -> Result<Self, SpawnError>
pub fn with_config( spawner: RuntimeSpawner, config: SupervisorConfig, ) -> Result<Self, SpawnError>
Start the dedicated supervisor OS thread. Thread-spawn failure is
SpawnError::ThreadSpawnFailed — same category-A surface as
super::runtime::Runtime::new, not a panic.
Sourcepub fn start_child(&self, spec: ChildSpec) -> Result<FlowHandle, SpawnError>
pub fn start_child(&self, spec: ChildSpec) -> Result<FlowHandle, SpawnError>
Spawn spec and start supervising it. The returned handle is for
this incarnation only — a restart allocates a new Pid and a new
completion channel.
pub fn live_children(&self) -> usize
Sourcepub fn intensity_exceeded(&self) -> bool
pub fn intensity_exceeded(&self) -> bool
true once more than SupervisorConfig::max_restarts waves
landed inside the intensity window. Remaining children keep
running; we just stop bringing them back (no safe abort of a
mid-quantum flow).