Struct async_shutdown::VitalToken
source · pub struct VitalToken { /* 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 the rest of the clones still exist.
Implementations§
source§impl VitalToken
impl VitalToken
sourcepub fn wrap_vital<F: Future>(self, future: F) -> WrapVital<F> ⓘ
pub fn wrap_vital<F: Future>(self, future: F) -> WrapVital<F> ⓘ
Wrap a future to cause 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 = vital_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 Clone for VitalToken
impl Clone for VitalToken
source§fn clone(&self) -> VitalToken
fn clone(&self) -> VitalToken
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 Freeze for VitalToken
impl RefUnwindSafe for VitalToken
impl Send for VitalToken
impl Sync for VitalToken
impl Unpin for VitalToken
impl UnwindSafe for VitalToken
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