pub struct CancellationToken { /* private fields */ }Expand description
Propagates notification that operations should be canceled.
Implementations§
Source§impl CancellationToken
impl CancellationToken
Sourcepub fn can_be_canceled(&self) -> bool
pub fn can_be_canceled(&self) -> bool
Whether this token is capable of being in the canceled state.
pub fn is_cancellation_requested(&self) -> bool
Sourcepub fn register(
&self,
callback: impl FnOnce() + Send + 'static,
) -> CancellationTokenRegistration
pub fn register( &self, callback: impl FnOnce() + Send + 'static, ) -> CancellationTokenRegistration
Registers a callback that runs when the token is canceled. When the token is already canceled the callback runs immediately.
Source§impl CancellationToken
impl CancellationToken
Sourcepub fn register_local(
&self,
callback: impl FnOnce() + 'static,
) -> LocalCancellationTokenRegistration
pub fn register_local( &self, callback: impl FnOnce() + 'static, ) -> LocalCancellationTokenRegistration
Registers a callback that runs on the current thread when the token is canceled: at once
when it is canceled on this thread, or already canceled; through the poster of this thread,
or its queue of run_pending_wakes, when it is
canceled on another thread. The callback need not be Send.
Trait Implementations§
Source§impl Clone for CancellationToken
impl Clone for CancellationToken
Auto 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