Skip to main content

ShutdownSignal

Struct ShutdownSignal 

Source
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

Source

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.

Trait Implementations§

Source§

impl Future for ShutdownSignal

Source§

type Output = ()

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.