pub struct CancellationToken { /* private fields */ }Expand description
Cancellation signal shared by a task store and the work it owns.
Cloned tokens share the same underlying signal: cancelling any clone
cancels them all. The token is backed by
tokio_util::sync::CancellationToken, so it can be checked synchronously
or awaited. A store must raise the same signal for explicit cancellation
and expiry; see TaskStore::create_task.
This task-lifecycle token is intentionally a separate type from
crate::context::CancellationToken, which belongs to the originating
request.
Implementations§
Source§impl CancellationToken
impl CancellationToken
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, un-cancelled token.
TaskStore::create_task has to return one of these, so the public
constructor lets external task stores create the process-local signal
they bridge to durable cancellation and expiry state.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check whether cancellation or expiry has been signalled.
Trait Implementations§
Source§impl Clone for CancellationToken
impl Clone for CancellationToken
Source§fn clone(&self) -> CancellationToken
fn clone(&self) -> CancellationToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more