V
- The result type returned by the future.public class DelegatingListenableFuture<V> extends Object implements ListenableFuture<V>
Modifier and Type | Field and Description |
---|---|
protected ListenableFuture<? extends V> |
delegate
Delegate to which all method calls are delegated.
|
Constructor and Description |
---|
DelegatingListenableFuture(ListenableFuture<? extends V> delegate)
Creates a listenable future that delegates all method calls to the
specified listenable future.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addCompletionListener(FutureCompletionListener<? super V> listener)
Registers a completion listener with this future.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
V |
get() |
V |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
boolean |
removeCompletionListener(FutureCompletionListener<? super V> listener)
Removes the registration of a completion listener with this future.
|
protected ListenableFuture<? extends V> delegate
public DelegatingListenableFuture(ListenableFuture<? extends V> delegate)
delegate
- listenable future that will receive all method calls that are
made on this listenable future.public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<V>
public V get() throws InterruptedException, ExecutionException
get
in interface Future<V>
InterruptedException
ExecutionException
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<V>
InterruptedException
ExecutionException
TimeoutException
public boolean addCompletionListener(FutureCompletionListener<? super V> listener)
ListenableFuture
Registers a completion listener with this future. This listener is
notified when the future completes (Future.isDone()
returns
true
). If the future completes before the listener is
registered, the listener is notified immediately while being added.
If the specified listener is already registered with this future, no
action is taken and this method returns false
.
Important note: Typically, the listener is executed by
the thread that sets the future's value. For this reason, it is important
that the listener does not block or perform any long-running operations.
Instead, the listener should delegate any such operation to a different
thread (e.g. using an Executor
). Any violation of this rule might
result in unexpected or unpredictable behavior. In particular, a blocking
listener might cause a dead-lock, which results in the whole application
being stalled indefinitely.
addCompletionListener
in interface ListenableFuture<V>
listener
- listener to be registered with this future.true
if the listener has been added,
false
if it has already been added earlier.public boolean removeCompletionListener(FutureCompletionListener<? super V> listener)
ListenableFuture
Removes the registration of a completion listener with this future. After removing, the listener is not going to be notified when the future completes.
If the specified listener is not currently registered with this future,
no action is taken and this method returns false
.
removeCompletionListener
in interface ListenableFuture<V>
listener
- listener to be unregistered from this future.true
if the listener has been removed,
false
if it has already been removed earlier of if
has never been added.Copyright © 2014–2016 aquenos GmbH. All rights reserved.