Top Description Fields Constructors Methods
com.google.common.util.concurrent

pack-priv final Class ForwardingFluentFuture<V extends @Nullable Object>

extends FluentFuture<V extends @Nullable Object>
Class Inheritance
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

FluentFuture that forwards all calls to a delegate.

Extension

If you want a class like 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.

Field Summary

Modifier and TypeField and Description
private final ListenableFuture<V>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod 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.google.common.util.concurrent.AbstractFuture.addListener.

Implements com.google.common.util.concurrent.ListenableFuture.addListener.

Registers a listener to be run on the given executor.
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 complete
mayInterruptIfRunning
)

Overrides com.google.common.util.concurrent.AbstractFuture.cancel.

Implements java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task.
public V
get()

Overrides com.google.common.util.concurrent.AbstractFuture.get.

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.
public V
get(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Overrides com.google.common.util.concurrent.AbstractFuture.get.

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
public boolean
isCancelled()

Overrides com.google.common.util.concurrent.AbstractFuture.isCancelled.

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.
public boolean
isDone()

Overrides com.google.common.util.concurrent.AbstractFuture.isDone.

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.
public String
toString()

Overrides com.google.common.util.concurrent.AbstractFuture.toString.

Returns a string representation of the object.
Inherited from com.google.common.util.concurrent.FluentFuture:
addCallbackcatchingcatchingAsyncfromfromtransformtransformAsyncwithTimeoutwithTimeout

Field Detail

delegateback to summary
private final ListenableFuture<V> delegate

Constructor Detail

ForwardingFluentFutureback to summary
pack-priv ForwardingFluentFuture(ListenableFuture<V> delegate)

Method Detail

addListenerback to summary
public void addListener(Runnable listener, Executor executor)

Overrides com.google.common.util.concurrent.AbstractFuture.addListener.

Implements com.google.common.util.concurrent.ListenableFuture.addListener.

Doc from com.google.common.util.concurrent.AbstractFuture.addListener.

Registers a listener to be run on the given executor. The listener will run when the Future's computation is complete or, if the computation is already complete, immediately.

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 Executor.execute (e.g., a RejectedExecutionException or an exception thrown by direct execution) will be caught and logged.

Note

If your listener is lightweight -- and will not cause stack overflow by completing more futures or adding more directExecutor() listeners inline -- consider MoreExecutors#directExecutor. Otherwise, avoid it: See the warnings on the docs for directExecutor.

This is the most general listener interface. For common operations performed using listeners, see Futures. For a simplified but general listener interface, see addCallback().

Memory consistency effects: Actions in a thread prior to adding a listener happen-before its execution begins, perhaps in another thread.

Guava implementations of ListenableFuture promptly release references to listeners after executing them.

Parameters
listener:Runnable

Doc from com.google.common.util.concurrent.ListenableFuture.addListener.

the listener to run when the computation is complete

executor:Executor

Doc from com.google.common.util.concurrent.ListenableFuture.addListener.

the executor to run the listener in

Annotations
@Override
cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Overrides com.google.common.util.concurrent.AbstractFuture.cancel.

Implements java.util.concurrent.Future.cancel.

Doc from com.google.common.util.concurrent.AbstractFuture.cancel.

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 cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task (when known by the implementation) is interrupted in an attempt to stop the task.

The return value from this method does not necessarily indicate whether the task is now cancelled; use isCancelled.

If a cancellation attempt succeeds on a Future that had previously been set asynchronously, then the cancellation will also be propagated to the delegate Future that was supplied in the setFuture call.

Rather than override this method to perform additional cancellation work or cleanup, subclasses should override afterDone, consulting isCancelled and wasInterrupted as necessary. This ensures that the work is done even if the future is cancelled without a call to cancel, such as by calling setFuture(cancelledFuture).

Beware of completing a future while holding a lock. Its listeners may do slow work or acquire other locks, risking deadlocks.

Parameters
mayInterruptIfRunning:boolean

Doc from java.util.concurrent.Future.cancel.

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 complete

Returns:boolean

Doc from java.util.concurrent.Future.cancel.

false if the task could not be cancelled, typically because it has already completed; true otherwise. If two or more threads cause a task to be cancelled, then at least one of them returns true. Implementations may provide stronger guarantees.

Annotations
@Override
getback to summary
public V get() throws InterruptedException, ExecutionException

Overrides com.google.common.util.concurrent.AbstractFuture.get.

Implements java.util.concurrent.Future.get.

Doc from com.google.common.util.concurrent.AbstractFuture.get.

Waits if necessary for the computation to complete, and then retrieves its result.

The default AbstractFuture implementation throws InterruptedException if the current thread is interrupted during the call, even if the value is already available.

Returns:V

Doc from java.util.concurrent.Future.get.

the computed result

Annotations
@Override
@ParametricNullness
Exceptions
InterruptedException:

Doc from java.util.concurrent.Future.get.

if the current thread was interrupted while waiting

ExecutionException:

Doc from java.util.concurrent.Future.get.

if the computation threw an exception

getback to summary
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException

Overrides com.google.common.util.concurrent.AbstractFuture.get.

Implements java.util.concurrent.Future.get.

Doc from com.google.common.util.concurrent.AbstractFuture.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

The default AbstractFuture implementation throws InterruptedException if the current thread is interrupted during the call, even if the value is already available.

Parameters
timeout:long

Doc from java.util.concurrent.Future.get.

the maximum time to wait

unit:TimeUnit

Doc from java.util.concurrent.Future.get.

the time unit of the timeout argument

Returns:V

Doc from java.util.concurrent.Future.get.

the computed result

Annotations
@Override
@ParametricNullness
Exceptions
InterruptedException:

Doc from java.util.concurrent.Future.get.

if the current thread was interrupted while waiting

ExecutionException:

Doc from java.util.concurrent.Future.get.

if the computation threw an exception

TimeoutException:

Doc from java.util.concurrent.Future.get.

if the wait timed out

isCancelledback to summary
public boolean isCancelled()

Overrides com.google.common.util.concurrent.AbstractFuture.isCancelled.

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Returns:boolean

true if this task was cancelled before it completed

Annotations
@Override
isDoneback to summary
public boolean isDone()

Overrides com.google.common.util.concurrent.AbstractFuture.isDone.

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Returns:boolean

true if this task completed

Annotations
@Override
toStringback to summary
public String toString()

Overrides com.google.common.util.concurrent.AbstractFuture.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override