TimeOutToken class

Time-out cancellation tokens used by callers of worker services. The token is cancelled automatically after a period of time indicated by duration with a countdown starting only when the task is assigned to a platform worker.

Inheritance

Constructors

TimeOutToken(Duration duration, [String message = 'The token timed out'])

Properties

cancelled bool
Flag indicating whether the token was cancelled or not.
no setterinherited
duration Duration
Duration of the timeout. The timer is not started before task is scheduled on a platform worker.
final
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
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
started bool
Returns true if the timeout has started, false otherwise.
no setter

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, time-out tokens may not be cancelled programmatically.
override
ensureStarted() → void
Called just before processing a WorkerRequest. The onTimeout callback may not be null, and a timer will be started that will automatically cancel this token if processing takes longer than duration.
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