- Index
- »
- concurrent
- »
- Future
type
Future
@Js
abstract const class Future : Obj
Future represents the result of an asynchronous computation.
See Actors
methods
| cancel |
Cancel this computation if it has not begun processing. |
|---|---|
| complete |
Complete the future successfully with given value. |
| completeErr |
Complete the future with a failure condition using given exception. |
| err |
Return the exception raised by the asynchronous computation or null if the future completed successfully. |
| get |
Block current thread until result is ready. |
| makeCompletable |
Construct a completable future instance in the pending state. |
| promise |
Get JavaScript Promise object which backs this Future. |
| status |
Current state of asynchronous computation |
| then |
Register a callback function when this future completes in either the ok or err/cancel state. |
| waitFor |
Block until this future transitions to a completed state (ok, err, or canceled). |
| waitForAll |
Block on a list of futures until they all transition to a completed state. |
Slot Details
cancel
Void cancel()
Cancel this computation if it has not begun processing. No guarantee is made that the computation will be cancelled.
complete
completeErr
err
Err? err()
Return the exception raised by the asynchronous computation or null if the future completed successfully. This method can only be used after completion, otherwise if status pending then raise NotCompleteErr.
get
makeCompletable
static Future makeCompletable()
Construct a completable future instance in the pending state.
promise
Obj promise()
Get JavaScript Promise object which backs this Future. Only available in JavaScript environments.
status
FutureStatus status()
Current state of asynchronous computation
then
This then(|Obj?->Obj?| onOk, |Err->Obj?|? onErr := null)
Register a callback function when this future completes in either the ok or err/cancel state. Return a new future that may be chained for additional async operations that will return the result of the given callback.
In the Java VM this operation is a blocking operation that has the same effect as calling waitFor and then invoking the given callback with the result of get or err.
In JavaScript this operation wraps Promise.then with the same semantics.