class Future(T)
- Future(T)
- Reference
- Object
Overview
A Future represents a value which may or may not currently be available, but will be available at some point, or an exception if that value could not be made available.
Defined in:
concur/future.crConstructors
Instance Method Summary
- #await(t : Time::Span) : T | Exception
-
#await : T | Exception
Awaits the completion of the future and returns either a value or an exception.
- #await!(t : Time::Span) : T
-
#await! : T
Awaits the completion of the future and either returns the computed value or raises an exception.
-
#done?
Returns
trueif the future has completed - either with a value or an exception. -
#flat_map(&block : T -> Future(K)) : Future(K) forall K
Creates a new future by applying a function to the successful result of this future, and returns the result of the function as the new future.
-
#flatten
Creates a new future with one level of nesting flattened.
-
#map(&block : T -> K) : Future(K) forall K
Creates a new future by applying a function to the successful result of this future.
-
#map_to(typ : Object.class)
Creates a new Future which is completed with this Future's result if that conforms to type
typor aTypeCastErrorotherwise. -
#on_complete(&block : T | Exception -> _) : Future(T)
Applies the side-effecting function to the result of this future, and returns a new future with the result of this future.
-
#on_error(&block : Exception -> _) : Future(T)
Applies the side-effecting function to the result of this future if it raised an error, and returns a new future with the result of this future.
-
#on_success(&block : T -> _) : Future(T)
Applies the side-effecting function to the result of this future if it was successful, and returns a new future with the result of this future.
-
#recover(&block : Exception -> T) : Future(T)
Creates a new future that will handle any matching throwable that this future might contain.
-
#select(&block : T -> Bool) : Future(T)
Creates a new future by filtering the value of the current future with a predicate.
-
#transform(&block : T | Exception -> K) : Future(K) forall K
Creates a new Future by applying the specified function to the result of this Future.
-
#zip(other : Future(K), &block : T, K -> W) : Future(W) forall K, W
Creates a new future holding the result of
blockapplied to the tuple of values from two futures.
Constructor Detail
Instance Method Detail
Awaits the completion of the future and returns either a value or an exception.
Awaits the completion of the future and either returns the computed value or raises an exception.
Returns true if the future has completed - either with a value or an exception.
Returns false otherwise.
Creates a new future by applying a function to the successful result of this future, and returns the result of the function as the new future.
If this future is completed with an exception then the new future will also contain this exception.
Creates a new future by applying a function to the successful result of this future.
If this future is completed with an exception then the new future will also contain this exception.
Creates a new Future which is completed with this Future's result if
that conforms to type typ or a TypeCastError otherwise.
Applies the side-effecting function to the result of this future, and returns a new future with the result of this future.
This method allows one to enforce that the callbacks are executed in a specified order.
Note: if one of the chained #on_complete callbacks throws an exception, that exception is not
propagated to the subsequent #on_complete callbacks. Instead, the subsequent #on_complete callbacks
are given the original value of this future.
Applies the side-effecting function to the result of this future if it raised an error, and returns a new future with the result of this future.
WARNING Will not be called if this future is never completed or if it is completed with success.
Applies the side-effecting function to the result of this future if it was successful, and returns a new future with the result of this future.
WARNING Will not be called if this future is never completed or if it is completed with an error.
Creates a new future that will handle any matching throwable that this future might contain. If there is no match, or if this future contains a valid result then the new future will contain the same.
Creates a new future by filtering the value of the current future with a predicate.
If the current future contains a value which satisfies the predicate, the new future will also hold that value.
Otherwise, the resulting future will fail with a EmptyError.
If the current future fails, then the resulting future also fails.
Creates a new Future by applying the specified function to the result of this Future.
If there is any non-fatal exception thrown when 'block' is applied then that exception will be propagated to the resulting future.
Creates a new future holding the result of block applied to the tuple of values from two futures.