PollableFuture<T> class

An implementation of Future that allows synchronously retrieving the value if it has already been completed.

A PollableFuture wraps an existing Future. Unless the PollableFuture is initialized with a non-Future value, it cannot be marked as completed until execution returns to the event loop after the underlying Future has completed. Consequently, a PollableFuture cannot be used to implement a spinlock that synchronously blocks while waiting for a Future to complete.

Implemented types
Available extensions

Constructors

PollableFuture(FutureOr<T> futureOrValue)
Constructor.

Properties

hashCode int
The hash code for this object.
no setterinherited
isCompleted bool
Returns true if the PollableFuture has completed, false otherwise.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
Returns the completed value.
no setter

Methods

asStream() Stream<T>
Creates a Stream containing the result of this future.
override
catchError(Function onError, {bool test(Object)?}) Future<T>
Handles errors emitted by this Future.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
then<R>(FutureOr<R> onValue(T), {Function? onError}) Future<R>
Register callbacks to be called when this future completes.
override
timeout(Duration timeLimit, {FutureOr<T> onTimeout()?}) Future<T>
Stop waiting for this future after timeLimit has passed.
override
toString() String
A string representation of this object.
inherited
whenComplete(FutureOr<void> action()) Future<T>
Registers a function to be called when this future completes.
override

Operators

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