pub struct CancellationToken { /* private fields */ }Expand description
Thread-safe cancellation token for query execution.
Uses an AtomicBool behind an Arc so cloning is O(1) and
every clone observes the same cancellation flag. Once
CancellationToken::cancel has been called, every subsequent
CancellationToken::check returns QueryCancelled until
CancellationToken::reset is called.
Implementations§
Source§impl CancellationToken
impl CancellationToken
pub fn new() -> Self
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Signal cancellation. Subsequent Self::check / Self::is_cancelled
observe the flag as set across all clones of this token.
Sourcepub fn reset(&self)
pub fn reset(&self)
Clear the cancellation signal for the next query. Operators
holding a clone of this token through their lifetime see the
reset on the next check.
pub fn is_cancelled(&self) -> bool
Sourcepub fn check(&self) -> Result<(), QueryCancelled>
pub fn check(&self) -> Result<(), QueryCancelled>
Return QueryCancelled if cancellation was signalled.
Ok(()) otherwise.
Designed for the inner loop of every operator: a single relaxed-ordered atomic load on the happy path.
Trait Implementations§
Source§impl Clone for CancellationToken
impl Clone for CancellationToken
Source§fn clone(&self) -> CancellationToken
fn clone(&self) -> CancellationToken
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CancellationToken
impl Debug for CancellationToken
Source§impl Default for CancellationToken
impl Default for CancellationToken
Source§fn default() -> CancellationToken
fn default() -> CancellationToken
Returns the “default value” for a type. Read more
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