@GwtCompatible class TrustedListenableFutureTask<V> extends AbstractFuture.TrustedFuture<V> implements java.util.concurrent.RunnableFuture<V>
RunnableFuture
that also implements the ListenableFuture
interface.
This should be used in preference to ListenableFutureTask
when possible for
performance reasons.
Modifier and Type | Class and Description |
---|---|
private class |
TrustedListenableFutureTask.TrustedFutureInterruptibleTask |
AbstractFuture.TrustedFuture<V>
Modifier and Type | Field and Description |
---|---|
private TrustedListenableFutureTask.TrustedFutureInterruptibleTask |
task |
Constructor and Description |
---|
TrustedListenableFutureTask(java.util.concurrent.Callable<V> callable) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterDone()
Callback method that is called exactly once after the future is completed.
|
(package private) static <V> TrustedListenableFutureTask<V> |
create(java.util.concurrent.Callable<V> callable)
Creates a
ListenableFutureTask that will upon running, execute the given
Callable . |
(package private) static <V> TrustedListenableFutureTask<V> |
create(java.lang.Runnable runnable,
V result)
Creates a
ListenableFutureTask that will upon running, execute the given
Runnable , and arrange that get will return the given result on successful
completion. |
void |
run() |
java.lang.String |
toString() |
addListener, cancel, get, get, isCancelled, isDone
interruptTask, maybePropagateCancellation, set, setException, setFuture, trustedGetException, wasInterrupted
private TrustedListenableFutureTask.TrustedFutureInterruptibleTask task
TrustedListenableFutureTask(java.util.concurrent.Callable<V> callable)
static <V> TrustedListenableFutureTask<V> create(java.util.concurrent.Callable<V> callable)
ListenableFutureTask
that will upon running, execute the given
Callable
.callable
- the callable taskstatic <V> TrustedListenableFutureTask<V> create(java.lang.Runnable runnable, @Nullable V result)
ListenableFutureTask
that will upon running, execute the given
Runnable
, and arrange that get
will return the given result on successful
completion.runnable
- the runnable taskresult
- the result to return on successful completion. If you don't need a particular
result, consider using constructions of the form:
ListenableFuture<?> f = ListenableFutureTask.create(runnable,
null)
public void run()
run
in interface java.lang.Runnable
run
in interface java.util.concurrent.RunnableFuture<V>
protected void afterDone()
AbstractFuture
If AbstractFuture.interruptTask()
is also run during completion, AbstractFuture.afterDone()
runs after it.
The default implementation of this method in AbstractFuture
does nothing. This is
intended for very lightweight cleanup work, for example, timing statistics or clearing fields.
If your task does anything heavier consider, just using a listener with an executor.
afterDone
in class AbstractFuture<V>
public java.lang.String toString()
toString
in class java.lang.Object