CompositeToken class

Composite cancellation token. The token is cancelled automatically depending on mode: with CompositeMode.any, the composite token is cancelled as soon as when one of the tokens is cancelled. With CompositeMode.any, the composite token is cancelled when all tokens are cancelled.

Inheritance

Constructors

CompositeToken(Iterable<CancellationToken> tokens, CompositeMode mode, [String message = 'The token was cancelled'])

Properties

cancelled bool
Flag indicating whether the token was cancelled or not.
no setterinherited
exception CancelledException?
Exception to be thrown upon cancellation
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
id String
The token's id
no setterinherited
message String?
Message associated with the token.
finalinherited
mode CompositeMode
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(SquadronCallback listener) → void
Registers a listener that will be notified when the token is cancelled. If the token is already cancelled, the listener will be called immediately.
inherited
cancel([CancelledException? exception]) → void
Throws an exception, composite tokens may not be cancelled programmatically.
override
ensureStarted() → void
Called just before processing a WorkerRequest. This method calls the ensureStarted method for all tokens registered with this CompositeToken.
override
isCancelled({bool throwIfCancelled = false}) Future<bool>
Await this method in Worker code to give cancellation requests a chance to come through.
inherited
isCancelledSync({bool throwIfCancelled = false}) bool
Synchronously check whether the token has been cancelled.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeListener(SquadronCallback listener) → void
Unregisters a listener that has been installed with addListener.
inherited
serialize() List
Seralization of a CancellationToken
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited