CancellationToken class

Base cancellation token.

Implementers

Constructors

CancellationToken([String? message])

Properties

cancelled bool
Flag indicating whether the token was cancelled or not.
no setter
exception CancelledException?
Exception to be thrown upon cancellation
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
The token's id
no setter
message String?
Message associated with the token.
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.
cancel([CancelledException? exception]) → void
Cancels the token and notifies listeners.
ensureStarted() → void
Called just before processing a WorkerRequest, but should only be implemented by cancellation tokens that need to cancel automatically (eg. a timeout token).
isCancelled({bool throwIfCancelled = false}) Future<bool>
Await this method in Worker code to give cancellation requests a chance to come through.
isCancelledSync({bool throwIfCancelled = false}) bool
Synchronously check whether the token has been cancelled.
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.
serialize() List
Seralization of a CancellationToken
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

deserialize(List? token) CancellationToken?
Deseralization of a CancellationToken