com.google.common.util.concurrent
Class ForwardingListenableFuture<V>
java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.util.concurrent.ForwardingFuture<V>
com.google.common.util.concurrent.ForwardingListenableFuture<V>
- Type Parameters:
V
- The result type returned by this Future's get method
- All Implemented Interfaces:
- ListenableFuture<V>, Future<V>
@Beta
public abstract class ForwardingListenableFuture<V>
- extends ForwardingFuture<V>
- implements ListenableFuture<V>
A ForwardingFuture
that also implements ListenableFuture
.
Subclasses will have to provide a delegate ListenableFuture
through
the delegate()
method.
- Since:
- 4
- Author:
- Shardul Deo
ForwardingListenableFuture
protected ForwardingListenableFuture()
- Constructor for use by subclasses.
delegate
protected abstract ListenableFuture<V> delegate()
- Description copied from class:
ForwardingObject
- Returns the backing delegate instance that methods are forwarded to.
Abstract subclasses generally override this method with an abstract method
that has a more specific return type, such as
ForwardingSet.delegate()
. Concrete subclasses override this method to supply
the instance being decorated.
- Specified by:
delegate
in class ForwardingFuture<V>
addListener
public void addListener(Runnable listener,
Executor exec)
- Description copied from interface:
ListenableFuture
Adds a listener and executor to the ListenableFuture.
The listener will be passed
to the executor for execution when the Future
's computation is
complete.
There is no guaranteed ordering of execution of listeners, they may get
called in the order they were added and they may get called out of order,
but any listener added through this method is guaranteed to be called once
the computation is complete.
- Specified by:
addListener
in interface ListenableFuture<V>
- Parameters:
listener
- the listener to run when the computation is complete.exec
- the executor to run the listener in.