Struct graceful_shutdown::Shutdown [−][src]
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]
self,
terminator: T
) -> WithTerminator<T>ⓘ
Notable traits for WithTerminator<T>
impl<T: Future<Output = ()>> Future for WithTerminator<T> type Output = ();
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
Auto Trait Implementations
impl RefUnwindSafe for Shutdown
[src]
impl Send for Shutdown
[src]
impl Sync for Shutdown
[src]
impl Unpin for Shutdown
[src]
impl UnwindSafe for Shutdown
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<F> IntoFuture for F where
F: Future,
[src]
F: Future,
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type Future = F
into_future
)Which kind of future are we turning this into?
pub fn into_future(self) -> <F as IntoFuture>::Future
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,