pub struct CancelToken { /* private fields */ }Expand description
A cancellation flag. Clones share one flag; a child has
its own, and is cancelled when it or any ancestor is.
A function reads the run’s token through
Ctx::cancel, and hands a child to a run
it starts, so cancelling the parent cancels both.
use dataflow_rs::run::CancelToken;
let parent = CancelToken::new();
let child = parent.child();
child.cancel();
assert!(child.is_cancelled() && !parent.is_cancelled());
let other = parent.child();
parent.cancel();
assert!(other.is_cancelled());Implementations§
Source§impl CancelToken
impl CancelToken
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Cancels this token, its clones and every child made from them.
Every task awaiting cancelled on them is woken.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether this token or any of its ancestors was cancelled.
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