pub struct CancellationToken(/* private fields */);Expand description
An atomic cancellation flag that generation/verification loops poll.
Each token owns its own flag (so tests never perturb one another), and every
token additionally observes the process-level interrupt flag set by the
installed Ctrl-C handler. A loop calls check each iteration
and returns the resulting error so registered spool/output guards clean up
as the stack unwinds.
Implementations§
Source§impl CancellationToken
impl CancellationToken
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Request cancellation. Used by tests and by any caller that decides to abort; the installed signal handler flips the process-level flag every token also observes.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether this token (or the process) has been cancelled.
The flag is a single-writer, single-bit latch (never un-set) used only to
decide whether to stop, so a Relaxed load on the polling path is
sufficient — no other memory is published through it. cancel stores with
SeqCst for an unambiguous happens-before with any later observer.
Sourcepub fn check(&self) -> Result<(), GenerateError>
pub fn check(&self) -> Result<(), GenerateError>
Ok(()) while running, or a GEN-CANCELLED error once cancelled — the
value a loop returns so its guards run.
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 moreSource§impl Default for CancellationToken
impl Default for CancellationToken
Source§fn default() -> CancellationToken
fn default() -> CancellationToken
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§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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