Skip to main content

Module shutdown

Module shutdown 

Source
Expand description

A latching, clone-able shutdown signal for a service’s run loops.

tokio::sync::Notify::notify_waiters stores no permit: it wakes only the futures already waiting at the instant it runs. A loop that is inside its body at that instant (building a snapshot, writing a frame) re-enters its select! with a fresh notified() that nothing will ever wake, so a shutdown that joins its tasks hangs until the service manager kills it.

Shutdown latches instead: Shutdown::trigger sets a flag and wakes every current waiter, and Shutdown::wait returns at once when the flag is already set, so a loop that reaches its select! after the trigger still stops.

Structs§

Shutdown
A cancellation handle every run loop awaits and the service triggers on SIGTERM / SIGINT. Cheap to clone (shared Arcs).