pub struct TriggerShutdownToken<T: Clone> { /* private fields */ }
Expand description
Token that triggers a shutdown when it is dropped.
The token can be cloned and sent to different threads and tasks freely. If one of the cloned tokens is dropped, a shutdown is triggered. Even if the rest of the clones still exist.
Implementations§
Source§impl<T: Clone> TriggerShutdownToken<T>
impl<T: Clone> TriggerShutdownToken<T>
Sourcepub fn wrap_future<F: Future>(self, future: F) -> WrapTriggerShutdown<T, F> ⓘ
pub fn wrap_future<F: Future>(self, future: F) -> WrapTriggerShutdown<T, F> ⓘ
Wrap a future to trigger a shutdown when it completes or is dropped.
This consumes the token to avoid accidentally dropping the token after wrapping a future and instantly causing a shutdown.
If you need to keep the token around, you can clone it first:
let future = trigger_shutdown_token.clone().wrap_future(future);
Sourcepub fn forget(self)
pub fn forget(self)
Drop the token without causing a shutdown.
This is equivalent to calling std::mem::forget()
on the token.
Trait Implementations§
Source§impl<T: Clone + Clone> Clone for TriggerShutdownToken<T>
impl<T: Clone + Clone> Clone for TriggerShutdownToken<T>
Source§fn clone(&self) -> TriggerShutdownToken<T>
fn clone(&self) -> TriggerShutdownToken<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for TriggerShutdownToken<T>
impl<T> RefUnwindSafe for TriggerShutdownToken<T>
impl<T> Send for TriggerShutdownToken<T>where
T: Send,
impl<T> Sync for TriggerShutdownToken<T>where
T: Send,
impl<T> Unpin for TriggerShutdownToken<T>
impl<T> UnwindSafe for TriggerShutdownToken<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more