T - the type of the eventual value of the Futurepublic interface Future<T> extends PartialFuture<T>
Future will be set exactly once to either a "completed" T
or to an unchecked exception. A Future is a special case of a
PartialFuture that cannot result in a checked exception.Future can be waited on by blocking, or by using asynchronous callbacks.| Modifier and Type | Method and Description |
|---|---|
<V> Future<V> |
flatMap(Function<? super T,Future<V>> m)
Applies the successful result of this operation as the input into another asynchronous
operation and returns a handle to that result.
|
T |
get()
Blocks until a value is set on this
Future and returns it. |
Throwable |
getError()
Gets the error from a
Future if it has been set to this state. |
T |
getInterruptibly()
Blocks until a value is set on this
Future and returns it. |
<V> Future<V> |
map(Function<? super T,V> m)
Apply a function to the successful result of this operation.
|
Future<T> |
rescueRuntime(Function<? super RuntimeException,Future<T>> m)
Returns a
Future that modifies the error behavior of this Future. |
blockInterruptibly, blockUntilReady, cancel, dispose, flatMap, isDone, isError, map, onReady, onReadyAlready, rescue, rescue<V> Future<V> map(Function<? super T,V> m)
map(), since it accepts only Functions that cannot throw checked
exceptions, returns a Future. Errors encountered
in the execution of this operation are sent to the resulting Future.Future is cancelled the input
Future will also be cancelled.m - the map to the conversion to be runFuture that passes errors and converts output of this Future.<V> Future<V> flatMap(Function<? super T,Future<V>> m)
Future is complete and a result
is returned, the Mapper m is invoked to begin a new asynchronous process
using the result. This version of
map(), since it accepts only Functions that cannot throw checked
exceptions, returns a Future.
Errors in the execution of either operation are sent to the resulting Future.Future is cancelled the input
Future will also be cancelled.m - the map to the asynchronous process to be runFuture that passes errors and converts output of this Future
to the output of another asynchronous process.Future<T> rescueRuntime(Function<? super RuntimeException,Future<T>> m)
Future that modifies the error behavior of this Future.
Since Future cannot be set to an Exception other than a
RuntimeException, the handling Function need not handle other,
more general, types. If an Error is the output of this process, this handler
is not invoked and that Error will be passed on to the resulting Future.m - the process to run that maps an error into another asynchronous operationFuture with modified error behaviorT get()
Future and returns it.
If this Future is set to a RuntimeException or Error, throws it.
A Future cannot be set to a checked exception, so there is no
need to throw from this call.get in interface PartialFuture<T>T getInterruptibly() throws InterruptedException
Future and returns it.
If this PartialFuture is set to an Exception or Error
this call will throw that error.getInterruptibly in interface PartialFuture<T>InterruptedException - if the blocked thread is interruptedThrowable getError()
Future if it has been set to this state. If
this Future is not yet set, or has not been set to an error, throws
an exception. Although this method returns a Throwable, the set of
possible return types is more limited. A Future is limited to being
set to an unchecked exceptions -- that is an Error or a
RuntimeException (or one of its subclasses).getError in interface PartialFuture<T>FutureIllegalStateException - if this Future is not in an error state