FluentFuture that forwards all calls to a delegate.
FluentFuture but with extra methods, we recommend declaring your
own subclass of ListenableFuture, complete with a method like from to adapt an
existing ListenableFuture, implemented atop a ForwardingListenableFuture that
forwards to that future and adds the desired methods.
| Modifier and Type | Field and Description |
|---|---|
| private final ListenableFuture |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | addListener(Runnable
the listener to run when the computation is complete listener, Executor the executor to run the listener in executor)Overrides com. Implements com. |
| public boolean | cancel(boolean
true if the thread
executing this task should be interrupted (if the thread is
known to the implementation); otherwise, in-progress tasks are
allowed to completeOverrides com. Implements java. |
| public V | get()
Overrides com. Implements java. |
| public V | get(long
the maximum time to wait timeout, TimeUnit the time unit of the timeout argument unit)Overrides com. Implements java. |
| public boolean | isCancelled()
Overrides com. Implements java. true if this task was cancelled before it completed
normally.
|
| public boolean | isDone()
Overrides com. Implements java. true if this task completed.
|
| public String | toString()
Overrides com. |
| delegate | back to summary |
|---|---|
| private final ListenableFuture<V> delegate | |
| ForwardingFluentFuture | back to summary |
|---|---|
| pack-priv ForwardingFluentFuture(ListenableFuture<V> delegate) | |
| addListener | back to summary |
|---|---|
| public void addListener(Runnable listener, Executor executor) Overrides com. Implements com. Doc from com. Registers a listener to be run on the given executor.
The listener will run when the There is no guaranteed ordering of execution of listeners, but any listener added through this method is guaranteed to be called once the computation is complete. Exceptions thrown by a listener will be propagated up to the executor. Any exception thrown
during Note If your listener is lightweight -- and will not cause stack overflow by completing
more futures or adding more This is the most general listener interface. For common operations performed using
listeners, see Memory consistency effects: Actions in a thread prior to adding a listener happen-before its execution begins, perhaps in another thread. Guava implementations of
| |
| cancel | back to summary |
|---|---|
| public boolean cancel(boolean mayInterruptIfRunning) Overrides com. Implements java. Doc from com. Attempts to cancel execution of this task. This method has no
effect if the task is already completed or cancelled, or could
not be cancelled for some other reason. Otherwise, if this
task has not started when The return value from this method does not necessarily
indicate whether the task is now cancelled; use If a cancellation attempt succeeds on a Rather than override this method to perform additional cancellation work or cleanup,
subclasses should override Beware of completing a future while holding a lock. Its listeners may do slow work or acquire other locks, risking deadlocks.
| |
| get | back to summary |
|---|---|
| public V get() throws InterruptedException, ExecutionException Overrides com. Implements java. Doc from com. Waits if necessary for the computation to complete, and then retrieves its result. The default
| |
| get | back to summary |
|---|---|
| public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Overrides com. Implements java. Doc from com. Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available. The default
| |
| isCancelled | back to summary |
|---|---|
| public boolean isCancelled() Overrides com. Implements java. Doc from java. Returns
| |
| isDone | back to summary |
|---|---|
| public boolean isDone() Overrides com. Implements java. Doc from java. Returns
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides com. Doc from java. Returns a string representation of the object. | |