pub struct Supervisor<const N: usize, T: Topology<N> = Ordered<N, { shape::ALL }>> { /* private fields */ }Expand description
Orchestrates a set of managed tasks across spawn / teardown / bring-up.
Owned by a single supervisor task. Concurrent access from other tasks goes
through each TaskNode’s own atomic state, not the Supervisor struct.
Implementations§
Source§impl<const N: usize, T: Topology<N>> Supervisor<N, T>
impl<const N: usize, T: Topology<N>> Supervisor<N, T>
Source§impl<const N: usize, T: Topology<N>> Supervisor<N, T>
impl<const N: usize, T: Topology<N>> Supervisor<N, T>
Sourcepub const fn new(graph: &'static Graph<N, T>) -> Self
pub const fn new(graph: &'static Graph<N, T>) -> Self
Create a supervisor from a statically-built graph.
Sourcepub async fn start(&self, spawner: &Spawner) -> Result<(), NodeFault>
pub async fn start(&self, spawner: &Spawner) -> Result<(), NodeFault>
Bring the graph from any quiescent state to running, in dependency
order — cold boot AND re-entry (a sub-graph supervisor is legitimately
start()/teardown()-cycled per app phase). Idempotent: running nodes
are skipped; detached nodes are skipped on re-entry (their instance
survived the teardown — the first start still spawns them, the flag is
app-set afterwards); a Pause instance parked by an earlier teardown is
resumed in place (never double-spawned; like
resume_pausable this bypasses the gate waits,
since the parked instance retains its resources and its slots are empty
by design). Mode::OnDemand nodes are skipped — they’re brought up at
Sourcepub async fn run(&self, spawner: &Spawner) -> NodeFault
pub async fn run(&self, spawner: &Spawner) -> NodeFault
Run this node to completion, handling start, driver, and monitoring.
Sourcepub async fn monitor(&self) -> Infallible
pub async fn monitor(&self) -> Infallible
Monitor node liveness beats and restart nodes that miss deadlines.
Sourcepub async fn start_node(
&self,
node: &'static TaskNode,
spawner: &Spawner,
) -> Result<(), NodeFault>
pub async fn start_node( &self, node: &'static TaskNode, spawner: &Spawner, ) -> Result<(), NodeFault>
Start a single node if it is not already running and not detached.
Sourcepub async fn stop_node(&self, node: &'static TaskNode) -> Result<(), NodeFault>
pub async fn stop_node(&self, node: &'static TaskNode) -> Result<(), NodeFault>
Stop a single node, waiting for its shutdown ack.
Sourcepub async fn teardown(&self) -> Result<(), NodeFault>
pub async fn teardown(&self) -> Result<(), NodeFault>
Stop every running node, dependents before their dependencies.
Down OnDemand nodes are skipped (no instance to ack). Pause-mode nodes
ack and park on wait_resume(); Terminate/OnDemand nodes exit.
The stop runs as a wave: a node is signalled once every dependent
stopping with it has acked — a deps: dependency keeps serving
through its dependents’ cleanup — and a node with no such dependents
Sourcepub async fn teardown_continue(&self) -> Result<(), NodeFault>
pub async fn teardown_continue(&self) -> Result<(), NodeFault>
Like teardown, but do not clear the shutdown flags
so a later respawn_terminate can restart.
Sourcepub fn resume_node(&self, node: &'static TaskNode)
pub fn resume_node(&self, node: &'static TaskNode)
Resume a single parked Pause-mode node.
Sourcepub fn resume_pausable(&self)
pub fn resume_pausable(&self)
Signal every parked Pause-mode node to resume. Cheap and synchronous —
the tasks were parked on wait_resume() and pick up immediately. Called
separately from respawn_terminate so the application can fire resume
independently of the respawn step. Disabled (manually-paused) nodes are
skipped so a manual pause sticks, detached (self-managed) Pause nodes are
left parked, and — as in resume_node — a node
without a parked instance (has_acked_stop) is skipped: signaling it
would latch resume_wake with no waiter, and the node’s next park
Source§impl<const N: usize, T: Topology<N>> Supervisor<N, T>
impl<const N: usize, T: Topology<N>> Supervisor<N, T>
Sourcepub async fn apply_control(
&self,
cmd: ControlCommand,
spawner: &Spawner,
) -> Result<(), NodeFault>
pub async fn apply_control( &self, cmd: ControlCommand, spawner: &Spawner, ) -> Result<(), NodeFault>
Apply a control command to the requested node.
Sourcepub async fn deactivate(
&self,
target: &'static TaskNode,
) -> Result<(), NodeFault>
pub async fn deactivate( &self, target: &'static TaskNode, ) -> Result<(), NodeFault>
Deactivate the target node and all of its dependents.
Sourcepub async fn activate(&self, target: &'static TaskNode, spawner: &Spawner)
pub async fn activate(&self, target: &'static TaskNode, spawner: &Spawner)
Bring target (and its pool, and every transitive dependency) up, in
topological order so each dependency starts before its dependent — the
cascading “turn this subsystem on” verb, and the entry half of the
subordinate sub-graph pattern’s one-graph variant: activate on a