pub struct CancelToken { /* private fields */ }Expand description
Shared cancel flag. Clones observe the same flag.
Implementations§
Source§impl CancelToken
impl CancelToken
pub fn new() -> Self
Sourcepub fn from_flag(flag: Arc<AtomicBool>) -> Self
pub fn from_flag(flag: Arc<AtomicBool>) -> Self
Adopt an existing flag: the token observes (and sets) that same Arc, so a caller that
already owns a cancel flag (for example a task guard) shares it instead of copying it.
Sourcepub fn flag(&self) -> &Arc<AtomicBool> ⓘ
pub fn flag(&self) -> &Arc<AtomicBool> ⓘ
The shared flag itself, to hand to code that owns an Arc<AtomicBool>.
pub fn is_cancelled(&self) -> bool
Sourcepub fn as_atomic(&self) -> &AtomicBool
pub fn as_atomic(&self) -> &AtomicBool
The underlying flag, for APIs that take &AtomicBool.
Trait Implementations§
Source§impl Clone for CancelToken
impl Clone for CancelToken
Source§impl Debug for CancelToken
impl Debug for CancelToken
Auto Trait Implementations§
impl Freeze for CancelToken
impl RefUnwindSafe for CancelToken
impl Send for CancelToken
impl Sync for CancelToken
impl Unpin for CancelToken
impl UnsafeUnpin for CancelToken
impl UnwindSafe for CancelToken
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