pub struct CancellationContext { /* private fields */ }Expand description
Represents context for cancelling workflow or task evaluation.
Uses a default failure mode of Slow.
Implementations§
Source§impl CancellationContext
impl CancellationContext
Sourcepub fn new(mode: FailureMode) -> Self
pub fn new(mode: FailureMode) -> Self
Constructs a cancellation context for the given FailureMode.
If the provided mode is Slow, the first call to
cancel will wait for currently executing tasks to
complete; a subsequent call to cancel will cancel the
currently executing tasks.
If the provided mode is Fast, the first call to
cancel will cancel the currently executing tasks.
Sourcepub fn state(&self) -> CancellationContextState
pub fn state(&self) -> CancellationContextState
Gets the CancellationContextState of this CancellationContext.
Sourcepub fn cancel(&self) -> CancellationContextState
pub fn cancel(&self) -> CancellationContextState
Performs a cancellation.
Returns the current CancellationContextState which should be checked
to ensure the desired cancellation occurred.
This method will never return a
CancellationContextState::NotCanceled state.
Sourcepub fn first(&self) -> CancellationToken
pub fn first(&self) -> CancellationToken
Gets the cancellation token that is canceled upon the first cancellation.
The token will be canceled when CancellationContext::cancel is
called and the resulting state is CancellationContextState::Waiting
or CancellationContextState::Canceling.
Callers should not directly cancel the returned token and instead call
CancellationContext::cancel.
Sourcepub fn second(&self) -> CancellationToken
pub fn second(&self) -> CancellationToken
Gets the cancellation token that is canceled upon the second cancellation when the failure mode is “slow” or first cancellation when the failure mode is “fast”.
The token will be canceled when CancellationContext::cancel is
called and the resulting state is
CancellationContextState::Canceling.
Callers should not directly cancel the returned token and instead call
CancellationContext::cancel.
Trait Implementations§
Source§impl Clone for CancellationContext
impl Clone for CancellationContext
Source§fn clone(&self) -> CancellationContext
fn clone(&self) -> CancellationContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CancellationContext
impl Debug for CancellationContext
Auto Trait Implementations§
impl Freeze for CancellationContext
impl RefUnwindSafe for CancellationContext
impl Send for CancellationContext
impl Sync for CancellationContext
impl Unpin for CancellationContext
impl UnwindSafe for CancellationContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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