class TrustedListenableFutureTask<V> extends FluentFuture.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.TrustedFutureInterruptibleAsyncTask |
private class |
TrustedListenableFutureTask.TrustedFutureInterruptibleTask |
FluentFuture.TrustedFuture<V>
AbstractFuture.Trusted<V>
Modifier and Type | Field and Description |
---|---|
private InterruptibleTask<?> |
task |
GENERATE_CANCELLATION_CAUSES
Constructor and Description |
---|
TrustedListenableFutureTask(AsyncCallable<V> callable) |
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(AsyncCallable<V> callable) |
(package private) static <V> TrustedListenableFutureTask<V> |
create(java.util.concurrent.Callable<V> 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. |
protected java.lang.String |
pendingToString()
Provide a human-readable explanation of why this future has not yet completed.
|
void |
run() |
addListener, cancel, get, get, isCancelled, isDone
addCallback, catching, catchingAsync, from, from, transform, transformAsync, withTimeout, withTimeout
interruptTask, maybePropagateCancellationTo, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted
@CheckForNull private volatile InterruptibleTask<?> task
TrustedListenableFutureTask(java.util.concurrent.Callable<V> callable)
TrustedListenableFutureTask(AsyncCallable<V> callable)
static <V> TrustedListenableFutureTask<V> create(AsyncCallable<V> callable)
static <V> TrustedListenableFutureTask<V> create(java.util.concurrent.Callable<V> callable)
static <V> TrustedListenableFutureTask<V> create(java.lang.Runnable runnable, 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>
@CheckForNull protected java.lang.String pendingToString()
AbstractFuture
pendingToString
in class AbstractFuture<V>