| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.common.util.concurrent.AbstractCheckedFuture<V,E>
@Beta public abstract class AbstractCheckedFuture<V,E extends Exception>
A delegating wrapper around a ListenableFuture that adds support for
 the checkedGet() and checkedGet(long, TimeUnit) methods.
| Field Summary | |
|---|---|
protected  ListenableFuture<V> | 
delegate
The delegate, used to pass along all our methods.  | 
| Constructor Summary | |
|---|---|
protected  | 
AbstractCheckedFuture(ListenableFuture<V> delegate)
Constructs an AbstractCheckedFuture that wraps a delegate. | 
| Method Summary | |
|---|---|
 void | 
addListener(Runnable listener,
                       Executor exec)
Adds a listener and executor to the ListenableFuture.  | 
 boolean | 
cancel(boolean mayInterruptIfRunning)
Attempts to cancel execution of this task.  | 
 V | 
checkedGet()
Exception checking version of Future.get() that will translate
 InterruptedException, CancellationException and
 ExecutionException into application-specific exceptions. | 
 V | 
checkedGet(long timeout,
                     TimeUnit unit)
Exception checking version of Future.get(long, TimeUnit) that will
 translate InterruptedException, CancellationException and
 ExecutionException into application-specific exceptions. | 
 V | 
get()
Waits if necessary for the computation to complete, and then retrieves its result.  | 
 V | 
get(long timeout,
       TimeUnit unit)
Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.  | 
 boolean | 
isCancelled()
Returns true if this task was cancelled before it completed normally.  | 
 boolean | 
isDone()
Returns true if this task completed.  | 
protected abstract  E | 
mapException(Exception e)
Translate from an InterruptedException,
 CancellationException or ExecutionException to an exception
 of type E. | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected final ListenableFuture<V> delegate
| Constructor Detail | 
|---|
protected AbstractCheckedFuture(ListenableFuture<V> delegate)
AbstractCheckedFuture that wraps a delegate.
| Method Detail | 
|---|
protected abstract E mapException(Exception e)
InterruptedException,
 CancellationException or ExecutionException to an exception
 of type E.  Subclasses must implement the mapping themselves.
 
 The e parameter can be an instance of InterruptedException,
 CancellationException, or ExecutionException.
public V checkedGet()
             throws E extends Exception
CheckedFutureFuture.get() that will translate
 InterruptedException, CancellationException and
 ExecutionException into application-specific exceptions.
checkedGet in interface CheckedFuture<V,E extends Exception>E - on interruption, cancellation or execution exceptions.
E extends Exception
public V checkedGet(long timeout,
                    TimeUnit unit)
             throws TimeoutException,
                    E extends Exception
CheckedFutureFuture.get(long, TimeUnit) that will
 translate InterruptedException, CancellationException and
 ExecutionException into application-specific exceptions.  On
 timeout this method throws a normal TimeoutException.
checkedGet in interface CheckedFuture<V,E extends Exception>TimeoutException - if retrieving the result timed out.
E - on interruption, cancellation or execution exceptions.
E extends Exceptionpublic boolean cancel(boolean mayInterruptIfRunning)
java.util.concurrent.FutureAfter this method returns, subsequent calls to Future.isDone() will
 always return true.  Subsequent calls to Future.isCancelled()
 will always return true if this method returned true.
cancel in interface Future<V>mayInterruptIfRunning - true if the thread executing this
 task should be interrupted; otherwise, in-progress tasks are allowed
 to complete
public boolean isCancelled()
java.util.concurrent.Future
isCancelled in interface Future<V>public boolean isDone()
java.util.concurrent.Future
isDone in interface Future<V>
public V get()
      throws InterruptedException,
             ExecutionException
java.util.concurrent.Future
get in interface Future<V>InterruptedException - if the current thread was interrupted
 while waiting
ExecutionException - if the computation threw an
 exception
public V get(long timeout,
             TimeUnit unit)
      throws InterruptedException,
             ExecutionException,
             TimeoutException
java.util.concurrent.Future
get in interface Future<V>timeout - the maximum time to waitunit - the time unit of the timeout argument
InterruptedException - if the current thread was interrupted
 while waiting
ExecutionException - if the computation threw an
 exception
TimeoutException - if the wait timed out
public void addListener(Runnable listener,
                        Executor exec)
ListenableFutureAdds 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.
addListener in interface ListenableFuture<V>listener - the listener to run when the computation is complete.exec - the executor to run the listener in.
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||