pub struct ShutdownSignal { /* private fields */ }Expand description
Future that resolves when shutdown is triggered.
Registers (and updates) a waker on every poll so that
ShutdownHandle::trigger() (or a signal handler) can wake the
awaiting task directly. The waker is overwritten on each poll to
handle the case where the future is re-polled from a different
task context.
Single waiter only. Only one task may await ShutdownSignal at a
time. If a second task polls while a waker is already registered, the
waker is replaced (not duplicated). For multi-waiter shutdown, use
CancellationToken instead.
Holds a raw pointer to the AtomicBool flag, valid for the lifetime
of the Runtime (which outlives block_on which outlives all tasks).
Implementations§
Source§impl ShutdownSignal
impl ShutdownSignal
Sourcepub fn current() -> ShutdownSignal ⓘ
pub fn current() -> ShutdownSignal ⓘ
Returns a ShutdownSignal future for the currently running runtime.
The returned future resolves when shutdown is triggered — either by
a Unix signal handler installed via
Runtime::install_signal_handlers
(SIGTERM / SIGINT) or by an explicit
ShutdownHandle::trigger call. Mirrors
tokio::runtime::Handle::current(). Read as
ShutdownSignal::current().await — “await the current shutdown
signal”.
Single waiter only — see the type-level docs. For multi-waiter
patterns, use CancellationToken.
§Panics
Panics if called outside a Runtime::block_on
context.