pub struct CancellationToken { /* private fields */ }Expand description
A token that can be used to signal cancellation to an ongoing operation.
The token itself is immutable, but can be used to check if cancellation has been requested. When a cancellation is requested, all handlers checking this token should terminate early.
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 cancel(&self)
pub fn cancel(&self)
Requests cancellation for this token.
This is idempotent - calling it multiple times has the same effect as calling it once.
Sourcepub fn was_cancellation_observed(&self) -> bool
pub fn was_cancellation_observed(&self) -> bool
Returns true once any poll has observed cancellation as requested.
Sourcepub fn cancelled_flag(&self) -> Arc<AtomicBool>
pub fn cancelled_flag(&self) -> Arc<AtomicBool>
Returns a clone of the inner cancellation flag.
This allows external systems (e.g. Universal Interface connectors) to
share the same AtomicBool via their own cancellation token type,
providing zero-overhead live propagation of cancellation signals.
Sourcepub fn cancellation_observation_latency(&self) -> Option<Duration>
pub fn cancellation_observation_latency(&self) -> Option<Duration>
Returns the first observed cancellation-poll latency from request to observation.
Trait Implementations§
Source§impl Clone for CancellationToken
impl Clone for CancellationToken
Source§fn clone(&self) -> CancellationToken
fn clone(&self) -> CancellationToken
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more