Class TrustedListenableFutureTask<V>
java.lang.Object
com.google.common.util.concurrent.internal.InternalFutureFailureAccess
com.google.common.util.concurrent.AbstractFuture<V>
com.google.common.util.concurrent.GwtFluentFutureCatchingSpecialization<V>
com.google.common.util.concurrent.FluentFuture<V>
com.google.common.util.concurrent.FluentFuture.TrustedFuture<V>
com.google.common.util.concurrent.TrustedListenableFutureTask<V>
- All Implemented Interfaces:
AbstractFuture.Trusted<V>
,ListenableFuture<V>
,Runnable
,Future<V>
,RunnableFuture<V>
class TrustedListenableFutureTask<V>
extends FluentFuture.TrustedFuture<V>
implements RunnableFuture<V>
A
RunnableFuture
that also implements the ListenableFuture
interface.
This should be used in preference to ListenableFutureTask
when possible for
performance reasons.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
private final class
Nested classes/interfaces inherited from class com.google.common.util.concurrent.FluentFuture
FluentFuture.TrustedFuture<V>
Nested classes/interfaces inherited from class com.google.common.util.concurrent.AbstractFuture
AbstractFuture.Trusted<V>
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
FieldsFields inherited from class com.google.common.util.concurrent.AbstractFuture
GENERATE_CANCELLATION_CAUSES, log
-
Constructor Summary
ConstructorsConstructorDescriptionTrustedListenableFutureTask
(AsyncCallable<V> callable) TrustedListenableFutureTask
(Callable<V> callable) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
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> Creates aListenableFutureTask
that will upon running, execute the givenRunnable
, and arrange thatget
will return the given result on successful completion.(package private) static <V> TrustedListenableFutureTask
<V> protected String
Provide a human-readable explanation of why this future has not yet completed.void
run()
Methods inherited from class com.google.common.util.concurrent.FluentFuture.TrustedFuture
addListener, cancel, get, get, isCancelled, isDone
Methods inherited from class com.google.common.util.concurrent.FluentFuture
addCallback, catching, catchingAsync, from, from, transform, transformAsync, withTimeout, withTimeout
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
interruptTask, maybePropagateCancellationTo, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted
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, exceptionNow, get, get, isCancelled, isDone, resultNow, state
-
Field Details
-
task
-
-
Constructor Details
-
TrustedListenableFutureTask
-
TrustedListenableFutureTask
TrustedListenableFutureTask(AsyncCallable<V> callable)
-
-
Method Details
-
create
-
create
-
create
Creates aListenableFutureTask
that will upon running, execute the givenRunnable
, and arrange thatget
will return the given result on successful completion.- Parameters:
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)
-
run
public void run()- Specified by:
run
in interfaceRunnable
- Specified by:
run
in interfaceRunnableFuture<V>
-
afterDone
protected void afterDone()Description copied from class:AbstractFuture
Callback method that is called exactly once after the future is completed.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.- Overrides:
afterDone
in classAbstractFuture<V>
-
pendingToString
Description copied from class:AbstractFuture
Provide a human-readable explanation of why this future has not yet completed.- Overrides:
pendingToString
in classAbstractFuture<V>
- Returns:
- null if an explanation cannot be provided (e.g. because the future is done).
-