pub struct CancelToken(/* private fields */);Expand description
Cloneable cancellation flag shared between the apply worker and any number of signalling threads.
Clone is O(1) — every handle points at the same underlying
AtomicBool. Marking the token cancelled from any handle is visible to
every other handle on the next Self::is_cancelled poll.
§Threading
Send + Sync is automatic: the inner Arc of AtomicBool is
trivially shareable across threads. Construct on one thread, clone, and
hand the clones to wherever they need to live.
§Cost
Self::is_cancelled is a single Ordering::Relaxed atomic load and
is cheap enough to call from the inner SQPK block loop. Self::cancel
is one relaxed store. The token allocates one Arc-managed
AtomicBool at construction; clones share it.
Implementations§
Source§impl CancelToken
impl CancelToken
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Request cancellation.
Idempotent — calling this on an already-cancelled token is a no-op. The flip is immediately visible to every clone of this token.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true if Self::cancel has been called on any clone of
this token.
Uses Ordering::Relaxed — the apply driver polls this in hot
loops and only needs eventual visibility, not synchronisation with
any other memory ops.
Trait Implementations§
Source§impl Clone for CancelToken
impl Clone for CancelToken
Source§fn clone(&self) -> CancelToken
fn clone(&self) -> CancelToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CancelToken
impl Debug for CancelToken
Source§impl Default for CancelToken
impl Default for CancelToken
Source§fn default() -> CancelToken
fn default() -> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more