pub struct ControlWatcher;Expand description
Spawn-able helper that polls peek_interrupt and fires a
tokio::sync::Notify once an interrupt message is queued. The
orchestrator selects on the notify alongside the active worker run.
Implementations§
Source§impl ControlWatcher
impl ControlWatcher
Sourcepub async fn wait_for_interrupt(
paths: MissionPaths,
poll: Duration,
notify: Arc<Notify>,
)
pub async fn wait_for_interrupt( paths: MissionPaths, poll: Duration, notify: Arc<Notify>, )
Loop peek_interrupt every poll interval; when an interrupt is
seen, fire notify.notify_one() once and return. Poll errors are
logged and treated as “no interrupt yet” — the watcher never dies on a
transient filesystem hiccup.
notify_one (never notify_waiters) is load-bearing: it stores a
permit when nobody is waiting, so a fire while the run loop is between
notified() registrations (or still inside backend.start()) is
consumed by the NEXT waiter instead of being lost forever. Tokio also
re-stores/passes on the permit when a woken Notified future is
dropped unconsumed, so a select! race cannot swallow it either.