pub struct CancellationToken { /* private fields */ }Expand description
A thread-safe, cloneable cancellation token.
Tasks and effects receive a token and poll is_cancelled
to detect cancellation requests. Tokens are cheap to clone and share across
thread boundaries.
Implementations§
Source§impl CancellationToken
impl CancellationToken
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true if cancellation has been requested.
Sourcepub fn wait_timeout(&self, duration: Duration) -> bool
pub fn wait_timeout(&self, duration: Duration) -> bool
Block until either cancellation is requested or the timeout elapses.
Returns true if cancelled, false if timed out.
Trait Implementations§
Source§impl Clone for CancellationToken
impl Clone for CancellationToken
Source§fn clone(&self) -> CancellationToken
fn clone(&self) -> CancellationToken
Returns a duplicate 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 CancellationToken
impl RefUnwindSafe for CancellationToken
impl Send for CancellationToken
impl Sync for CancellationToken
impl Unpin for CancellationToken
impl UnsafeUnpin for CancellationToken
impl UnwindSafe for CancellationToken
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