pub struct CancelToken { /* private fields */ }Expand description
A handle into a cancel subtree.
Clone yields the same identity (same node), like the legacy token. A
cancel() cancels this token’s own subtree (epoch/fetch cancels are
legitimate); ancestors and siblings are unaffected. Two constructors mint a
fresh subtree root instead of deriving from a parent —
root, the owning master a subsystem holds and cancels
on teardown, and never, a sentinel that is never
cancelled. Both are covered by the cancel_root_sites guard.
Implementations§
Source§impl CancelToken
impl CancelToken
Sourcepub fn cancelled(&self) -> Cancelled<'_> ⓘ
pub fn cancelled(&self) -> Cancelled<'_> ⓘ
Future that resolves once this token’s subtree is cancelled. Cancel-safe
in tokio::select!: dropping it unregisters its slot.
pub fn is_cancelled(&self) -> bool
Sourcepub fn never() -> Self
pub fn never() -> Self
A token that is never cancelled — a placeholder where a token is required
but no cancellation source exists. The sentinel sibling of
root; both mint a fresh subtree root.
Sourcepub fn on_cancel<F>(&self, waker: F) -> CancelWakerGuard
pub fn on_cancel<F>(&self, waker: F) -> CancelWakerGuard
Register a synchronous waker fired when this token is cancelled — the sync
counterpart to cancelled for a thread parked
on a (flash-aware) Condvar/Notify. Registered on THIS node only; an
ancestor cancel() reaches it through the down-propagation drain.
The waker runs on the cancelling thread: keep it cheap, non-blocking, and idempotent. If the token is already cancelled it fires immediately. The returned guard unregisters the waker on drop — hold it for the wait’s lifetime.
Sourcepub fn root() -> Self
pub fn root() -> Self
Mint a fresh root of a new cancel subtree — the owning master a subsystem
holds and cancels on teardown. Drop is passive: dropping the root does
not cancel its subtree; teardown is an explicit cancel(). Minted only
at owner sites (enforced by the cancel_root_sites guard). For a token that
is structurally required but never cancelled, use
never instead.
Trait Implementations§
Source§impl BitOr<CancelGroup> for CancelToken
impl BitOr<CancelGroup> for CancelToken
Source§type Output = CancelGroup
type Output = CancelGroup
| operator.Source§fn bitor(self, rhs: CancelGroup) -> CancelGroup
fn bitor(self, rhs: CancelGroup) -> CancelGroup
| operation. Read moreSource§impl BitOr<CancelToken> for CancelGroup
impl BitOr<CancelToken> for CancelGroup
Source§type Output = CancelGroup
type Output = CancelGroup
| operator.Source§fn bitor(self, rhs: CancelToken) -> Self
fn bitor(self, rhs: CancelToken) -> Self
| operation. Read moreSource§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 more