pub struct CancelToken(/* private fields */);Expand description
A cooperative cancellation signal for a single engine call.
Cancellation is checked at engine checkpoints during both target preparation
and evaluation. Setting it does not abort work in progress; it causes the next
checkpoint to return ExcelErrorKind::Cancelled.
The token is a handle: cloning shares one signal, so a caller can hold a clone and cancel from another thread.
use formualizer_eval::engine::CancelToken;
let token = CancelToken::new();
let remote = token.clone();
assert!(!token.is_cancelled());
remote.cancel();
assert!(token.is_cancelled());The underlying representation is deliberately private so that richer
cancellation (cancellation reasons, linked child tokens) can be added without
a breaking change. Use CancelToken::from_flag to adopt a flag you already
own.
Implementations§
Source§impl CancelToken
impl CancelToken
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns whether cancellation has been signalled.
Sourcepub fn from_flag(flag: Arc<AtomicBool>) -> Self
pub fn from_flag(flag: Arc<AtomicBool>) -> Self
Adopts an existing flag, for callers that already own one or share it with non-engine code.
Sourcepub fn as_flag(&self) -> &Arc<AtomicBool> ⓘ
pub fn as_flag(&self) -> &Arc<AtomicBool> ⓘ
Borrows the underlying flag as a legacy/interoperability bridge.
New code should poll CancelToken::is_cancelled instead. The raw flag
may not represent future richer cancellation semantics.
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§
impl<T> Allocation for T
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> 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