pub struct DropGuard { /* private fields */ }Expand description
A wrapper for a CancellationToken which cancels it on drop, created by
CancellationToken::drop_guard.
use nuclei::sync::CancellationToken;
let token = CancellationToken::new();
let guard = token.clone().drop_guard();
let still_alive = guard.disarm();
assert!(!token.is_cancelled());
drop(still_alive);
assert!(!token.is_cancelled());Implementations§
Source§impl DropGuard
impl DropGuard
Sourcepub fn token(&self) -> &CancellationToken
pub fn token(&self) -> &CancellationToken
Returns a reference to the token this guard wraps.
Sourcepub fn disarm(self) -> CancellationToken
pub fn disarm(self) -> CancellationToken
Returns the token and disarms this guard: it no longer cancels the token. Other guards of the same token are not affected.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DropGuard
impl RefUnwindSafe for DropGuard
impl Send for DropGuard
impl Sync for DropGuard
impl Unpin for DropGuard
impl UnsafeUnpin for DropGuard
impl UnwindSafe for DropGuard
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