Struct graceful_shutdown::Shutdown[][src]

pub struct Shutdown { /* fields omitted */ }

Future for graceful shutdown.

Implementations

impl Shutdown[src]

pub fn new() -> Self[src]

pub fn handle(&self) -> Handle[src]

Get a reference to manage the Shutdown

pub fn with_terminator<T: Future<Output = ()>>(
    self,
    terminator: T
) -> WithTerminator<T>

Notable traits for WithTerminator<T>

impl<T: Future<Output = ()>> Future for WithTerminator<T> type Output = ();
[src]

Add an early termination condition.

After shutdown has been initiated, the terminator future will be run, and if it completes before all tasks are completed the shutdown future will complete, thus finishing the shutdown even if there are outstanding tasks. This can be useful for using a timeout or signal (or combination) to force a full shutdown even if one or more tasks are taking longer than expected to finish.

Note that terminator will not start to be polled until after shutdown has been initiated. However, you may need to delay creation of the actual timeout future until the first poll, so that the end time is set correctly. This can be done using something like

let shutdown = Shutdown::new().with_terminator(async {
    tokio::time::sleep(Duration::from_secs(30)).await;
});

Trait Implementations

impl Future for Shutdown[src]

type Output = ()

The type of value produced on completion.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

type Future = F

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.