MergedCancellationToken class
Merges multiple cancellation tokens into a single token.
Note that when using a MergedCancellationToken, the cancellation exception thrown isn't guaranteed to be the exception of the token that was cancelled first. If no cancellable operations were running when the tokens were cancelled, the exception from the first token in the list will be used.
- Implemented types
- Mixed in types
Constructors
-
MergedCancellationToken(List<
CancellationToken> tokens)
Properties
- cancellationStackTrace → StackTrace
-
The stack trace at the time this cancellable was created.
finalinherited
- exception → Exception?
-
The exception given when one of the merged tokens was cancelled.
no setteroverride
- hasCancellables → bool
-
Whether or not the token has any attached cancellables.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
Whether or not any of the merged tokens have been cancelled.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
attachCancellable(
Cancellable cancellable) → void -
Attaches a Cancellable to this token.
override
-
cancel(
[Exception? exception]) → void -
Cancels the token.
override
-
cancelWithReason(
String? reason) → void -
Cancels all operations using this token with a CancelledException that
includes the given
reason
.override -
detach(
) → void -
Detatches from the CancellationToken. This should be called after
completing without cancellation.
inherited
-
detachCancellable(
Cancellable cancellable) → void -
Detaches a Cancellable from this token.
override
-
maybeAttach(
CancellationToken? token) → bool -
Attaches to the CancellationToken only if it hasn't already been
cancelled. If the token has already been cancelled, onCancel is called
instead.
inherited
-
merge(
CancellationToken other) → MergedCancellationToken -
Merges this CancellationToken with another to create a single token
that will be cancelled when either token is cancelled.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCancel(
Exception cancelException) → void -
Handles the cancellation of a merged token that this token is currently
attached to.
override
-
throwIfCancelled(
) → void -
Throws the cancellation exception if the token has already been cancelled.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited