com.google.common.util.concurrent
Class ForwardingListenableFuture<V>

java.lang.Object
  extended by com.google.common.collect.ForwardingObject
      extended by com.google.common.util.concurrent.ForwardingFuture<V>
          extended by 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

Constructor Summary
protected ForwardingListenableFuture()
          Constructor for use by subclasses.
 
Method Summary
 void addListener(Runnable listener, Executor exec)
          Adds a listener and executor to the ListenableFuture.
protected abstract  ListenableFuture<V> delegate()
          Returns the backing delegate instance that methods are forwarded to.
 
Methods inherited from class com.google.common.util.concurrent.ForwardingFuture
cancel, get, get, isCancelled, isDone
 
Methods inherited from class com.google.common.collect.ForwardingObject
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.Future
cancel, get, get, isCancelled, isDone
 

Constructor Detail

ForwardingListenableFuture

protected ForwardingListenableFuture()
Constructor for use by subclasses.

Method Detail

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.