pub struct TaskNode { /* private fields */ }Expand description
A node in the supervisor’s task graph.
Designed to live in static memory: every field is Sync, all constructors
are const. Declared by supervisor_graph!, which emits one per managed
task along with the Graph (GRAPH) that Supervisor::new consumes.
Split in two on purpose. The handle’s atomics force this static into RAM —
and would force everything beside them into RAM too — so the node holds
only its live state plus one reference to its NodeCfg, the immutable
half (name, mode, spawn fn, gates, budgets, coupling tables), which has no
interior mutability and therefore stays in flash. Same lesson as the
graph’s Topology, one level down: keep the constant data out of reach
of the atomics.
Implementations§
Source§impl TaskNode
impl TaskNode
Sourcepub fn veto<const N: usize>(&self, s: Sig<VetoGate<N>>) -> Option<Veto<N>>
pub fn veto<const N: usize>(&self, s: Sig<VetoGate<N>>) -> Option<Veto<N>>
This node’s handle on the gate s, bound to the contributor slot the
graph assigned its writes: [.. veto] entry. None (and a warning)
when no such entry names the gate — a body reaching a gate its
declaration never claimed a slot in.
Source§impl TaskNode
impl TaskNode
Sourcepub fn beat_put<T: Sink + Sync>(&self, s: Sig<T>, v: T::Item)
pub fn beat_put<T: Sink + Sync>(&self, s: Sig<T>, v: T::Item)
Write v into s and record a heartbeat.
Sourcepub fn get<T: Source + Sync>(&self, s: Sig<T>) -> T::Item
pub fn get<T: Source + Sync>(&self, s: Sig<T>) -> T::Item
Read and return a snapshot of the signal s.
Sourcepub fn writer<T: Sync + ?Sized>(&self, s: Sig<T>) -> &'static T
pub fn writer<T: Sync + ?Sized>(&self, s: Sig<T>) -> &'static T
Borrow the signal target for a direct write, bypassing the Sink trait.
Sourcepub fn beat_writer<T: Sync + ?Sized>(&self, s: Sig<T>) -> &'static T
pub fn beat_writer<T: Sync + ?Sized>(&self, s: Sig<T>) -> &'static T
writer that is also the node’s sign of life — the
Source§impl TaskNode
impl TaskNode
Sourcepub async fn retire<T: Sync>(
&'static self,
s: Sig<Backed<T>>,
cooldown: Duration,
)
pub async fn retire<T: Sync>( &'static self, s: Sig<Backed<T>>, cooldown: Duration, )
Wait until no reader has held s for cooldown, then clear readiness
and, with control, request deactivation. If a reader arrives during
the wait, restart the cooldown. The readiness handshake keeps the stop
race-free: readers admitted after clear_ready wait for the next
activation instead of reading a producer that is shutting down.
Source§impl TaskNode
impl TaskNode
Sourcepub const fn new(cfg: &'static NodeCfg, disabled_at_boot: bool) -> Self
pub const fn new(cfg: &'static NodeCfg, disabled_at_boot: bool) -> Self
A node over its flash-resident NodeCfg. disabled_at_boot seeds
the node’s disabled flag so a control-started node (e.g. an OTA task)
can be declared down and started later via a control op. const;
supervisor_graph! emits the config static and this call together.
Sourcepub const fn name(&self) -> &'static str
pub const fn name(&self) -> &'static str
Human-readable name. Used in defmt logs and panic messages.
Sourcepub const fn ready_on_write(&self) -> bool
pub const fn ready_on_write(&self) -> bool
Does this node let an observed write assert its readiness?
Sourcepub const fn slot_timeout(&self) -> Duration
pub const fn slot_timeout(&self) -> Duration
This node’s pre-spawn gate-wait bound (see
with_slot_timeout). The whole-graph
waves budget all of a node’s gates together, from when its in-pass deps
resolve; the single-node path (start_node)
gives each gate — executor slot, each resources: slot, each ready
dep — the full budget.
Sourcepub const fn ack_timeout(&self) -> Duration
pub const fn ack_timeout(&self) -> Duration
How long a stop waits for this node’s shutdown ack before faulting it
(see with_ack_timeout). Both stop paths
honor it: the single-node wait, and the whole-graph wave, where each
node’s window runs from the moment it is signalled.
Sourcepub const fn ready_deps(&self) -> &'static [&'static TaskNode]
pub const fn ready_deps(&self) -> &'static [&'static TaskNode]
The deps whose readiness bring-up awaits before spawning this node (the
ready-marked subset of deps:). Empty when none are marked.
Sourcepub const fn beat_timeout(&self) -> Option<Duration>
pub const fn beat_timeout(&self) -> Option<Duration>
This node’s liveness budget, or None when it is not policed (see
with_beat_timeout).
Sourcepub const fn beat_window(&self) -> u8
pub const fn beat_window(&self) -> u8
Consecutive stale sweeps required before the monitor reports this node
(see with_beat_window).
Sourcepub const fn reads(&self) -> &'static [&'static [Coupling]]
pub const fn reads(&self) -> &'static [&'static [Coupling]]
The signals this node declares it consumes (reads:).
Sourcepub const fn writes(&self) -> &'static [&'static [Coupling]]
pub const fn writes(&self) -> &'static [&'static [Coupling]]
The signals this node declares it produces (writes:).
Sourcepub const fn bound_deps(&self) -> &'static [&'static TaskNode]
pub const fn bound_deps(&self) -> &'static [&'static TaskNode]
The bound-marked subset of deps: (see
with_bound_deps).
Sourcepub const fn graph(&self) -> &'static [Option<&'static TaskNode>]
pub const fn graph(&self) -> &'static [Option<&'static TaskNode>]
The node slots of the graph this node belongs to, #[cfg]-ed-out slots
included as None — the same table Graph::nodes exposes, reached
from a node rather than from the graph static. Empty for a node no
graph declared.
Sourcepub fn is_bound_stopped(&self) -> bool
pub fn is_bound_stopped(&self) -> bool
True while this node is down because a bound provider withdrew
readiness — as opposed to is_disabled, which means somebody stopped it
on purpose. The distinction matters: a bound stop must lift by itself
when the provider recovers, and a manual stop must not.
Sourcepub fn shutdown_requested(&self) -> bool
pub fn shutdown_requested(&self) -> bool
True if the supervisor has asked this node to shut down.
A Fault::Wedge hides the request until cleared.
Sourcepub async fn wait_shutdown(&self)
pub async fn wait_shutdown(&self)
Wait until the supervisor asks this node to shut down.
A Fault::Wedge keeps this pending until cleared.
Sourcepub fn ack_dropped(&self)
pub fn ack_dropped(&self)
Acknowledge that this node’s instance has dropped and notify waiters.
A Fault::Wedge swallows the ack until cleared.
Sourcepub fn release_claims(&self)
pub fn release_claims(&self)
Give back every divisible share this node holds (see
NodeCfg::with_claims). Idempotent: releasing an empty slot stores zero.
Sourcepub fn mark_exited(&self)
pub fn mark_exited(&self)
Mark the task as completed and acknowledge its drop. A wedge hides this until cleared.
Sourcepub fn inject(&self, fault: Fault) -> Result<(), InjectError>
pub fn inject(&self, fault: Fault) -> Result<(), InjectError>
Inject a fault, or clear it with Fault::None.
Stall, crash and hog need a task: shell; wedge works on any node.
Sourcepub fn clear_fault(&self)
pub fn clear_fault(&self)
Clear the injected fault and replay anything it withheld.
Sourcepub fn has_exited(&self) -> bool
pub fn has_exited(&self) -> bool
Return true if the node has been marked as exited.
Sourcepub fn clear_ready(&self)
pub fn clear_ready(&self)
Clear this node’s readiness.
Sourcepub async fn wait_ready(&self)
pub async fn wait_ready(&self)
Wait until this node becomes ready.
Sourcepub fn poll_observed_writes(&self) -> bool
pub fn poll_observed_writes(&self) -> bool
Return whether any observed beat coupling has changed since last call.
Sourcepub fn report_status(&self, status: &'static str)
pub fn report_status(&self, status: &'static str)
Report a status string for this node.
Sourcepub fn status(&self) -> Option<&'static str>
pub fn status(&self) -> Option<&'static str>
The node’s current self-description, if it reported one this activation.
Sourcepub fn ticks_since_beat(&self) -> u32
pub fn ticks_since_beat(&self) -> u32
Ticks since the last beat — where, with
dataflow, a write through the node’s verbs since the previous
call counts as one, granted here (wrapping arithmetic; correct
for gaps under the u32 tick wrap, ~71 min at 1 MHz — far above any sane
max_age).
Sourcepub fn is_stale(&self, max_age: Duration) -> bool
pub fn is_stale(&self, max_age: Duration) -> bool
True when the node is running but hasn’t beaten within max_age — the
alive-but-stalled detector (a task hogging nothing, parked on an await
that will never complete). Not-running nodes are never stale: a stopped
or completed node is down, which is_running/has_exited already
report. Complements the trace stall watermark, which catches the
opposite failure (a poll that never yields).
Sourcepub fn epoch(&self) -> u32
pub fn epoch(&self) -> u32
This node’s activation generation: 0 before the first spawn, then
incremented on every transition into running — a fresh spawn, a pool
grow, a respawn_terminate, or a Pause node’s resume.
The dependent-side answer to “my provider was restarted underneath
me”. deps: gates a spawn once; nothing re-gates a node that is
already running when one of its providers cycles. A consumer holding
derived state (a filter, a session, a cached handle) samples this once
and compares it each iteration — one relaxed load, cheap enough for a
1 kHz loop:
let mut seen = PROVIDER.epoch();
loop {
let sample = INPUT.wait().await;
let now = PROVIDER.epoch();
if now != seen {
seen = now;
filter.reset(); // the provider is a new instance; derived state is stale
}
// ...
}Sourcepub async fn wait_epoch_change(&self, seen: u32) -> u32
pub async fn wait_epoch_change(&self, seen: u32) -> u32
Wait until the node’s epoch counter differs from seen.
Sourcepub async fn wait_resume(&self)
pub async fn wait_resume(&self)
Wait until the supervisor signals this Pause-mode node to resume.
Sourcepub fn run_cancellable<F: Future>(
&self,
fut: F,
) -> impl Future<Output = Result<F::Output, Aborted>>
pub fn run_cancellable<F: Future>( &self, fut: F, ) -> impl Future<Output = Result<F::Output, Aborted>>
Run fut until it completes or the node is stopped, returning Aborted on stop.
Sourcepub fn run_cancellable_acked<F: Future>(
&self,
fut: F,
) -> impl Future<Output = Result<F::Output, Aborted>>
pub fn run_cancellable_acked<F: Future>( &self, fut: F, ) -> impl Future<Output = Result<F::Output, Aborted>>
Like run_cancellable, but also acks the stop handshake.
Sourcepub fn run_pausable<F: Future>(
&self,
fut: F,
) -> impl Future<Output = Result<F::Output, Resumed>>
pub fn run_pausable<F: Future>( &self, fut: F, ) -> impl Future<Output = Result<F::Output, Resumed>>
Run fut until it completes or the node is paused, returning Resumed on pause.
Sourcepub async fn run_pausable_loop(&self, body: impl AsyncFnMut()) -> !
pub async fn run_pausable_loop(&self, body: impl AsyncFnMut()) -> !
Run body in a run_pausable loop forever, surviving pause/resume cycles.
Sourcepub fn mark_busy(&self)
pub fn mark_busy(&self)
Mark this node as busy, requesting pool scale-out if one is configured.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Return true if the node has a running instance.
Sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Return true if the node has been manually disabled.
Sourcepub fn is_collateral(&self) -> bool
pub fn is_collateral(&self) -> bool
Return true if the node is held stopped as a dependent of a
deactivated node.
Sourcepub fn set_detached(&self, detached: bool)
pub fn set_detached(&self, detached: bool)
Set whether this node is detached from automatic lifecycle management.
Sourcepub fn is_detached(&self) -> bool
pub fn is_detached(&self) -> bool
Return true if the node is detached from automatic lifecycle management.
Sourcepub fn set_task_id(&self, id: u32)
pub fn set_task_id(&self, id: u32)
Record the executor task id for this node instance.
Sourcepub fn adopt<S>(&self, token: &SpawnToken<S>)
pub fn adopt<S>(&self, token: &SpawnToken<S>)
Adopt a spawn token’s task id (and name, if enabled) for tracing.
Sourcepub async fn adopt_current(&self)
pub async fn adopt_current(&self)
Adopt the current task’s id for tracing.
Sourcepub fn stamp_name<S>(&self, token: &SpawnToken<S>)
pub fn stamp_name<S>(&self, token: &SpawnToken<S>)
Set the spawn token’s task name to this node’s configured name.
Sourcepub fn exec_ticks(&self) -> u32
pub fn exec_ticks(&self) -> u32
Return the accumulated execution tick count for this node.
Sourcepub fn poll_count(&self) -> u32
pub fn poll_count(&self) -> u32
Return the number of poll cycles recorded for this node.
Sourcepub fn max_poll_ticks(&self) -> u32
pub fn max_poll_ticks(&self) -> u32
Return the longest single-poll tick count recorded for this node.
Sourcepub fn set_disabled(&self, disabled: bool)
pub fn set_disabled(&self, disabled: bool)
Manually disable or re-enable this node.