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
- 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
-
attach(
Cancellable cancellable) → void -
Attaches a Cancellable to this token.
override
-
cancel(
[Exception exception = const CancelledException()]) → void -
Cancels the token.
override
-
detach(
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, [StackTrace? stackTrace]) → void -
Handles the cancellation of a merged token that this token is currently
attached to.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited