Class TrustedListenableFutureTask<V>
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractFuture<V>
-
- com.google.common.util.concurrent.AbstractFuture.TrustedFuture<V>
-
- com.google.common.util.concurrent.TrustedListenableFutureTask<V>
-
- All Implemented Interfaces:
ListenableFuture<V>
,java.lang.Runnable
,java.util.concurrent.Future<V>
,java.util.concurrent.RunnableFuture<V>
@GwtCompatible class TrustedListenableFutureTask<V> extends AbstractFuture.TrustedFuture<V> implements java.util.concurrent.RunnableFuture<V>
ARunnableFuture
that also implements theListenableFuture
interface.This should be used in preference to
ListenableFutureTask
when possible for performance reasons.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
TrustedListenableFutureTask.TrustedFutureInterruptibleTask
-
Nested classes/interfaces inherited from class com.google.common.util.concurrent.AbstractFuture
AbstractFuture.TrustedFuture<V>
-
-
Field Summary
Fields Modifier and Type Field Description private TrustedListenableFutureTask.TrustedFutureInterruptibleTask
task
-
Constructor Summary
Constructors Constructor Description TrustedListenableFutureTask(java.util.concurrent.Callable<V> callable)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
afterDone()
Callback method that is called exactly once after the future is completed.(package private) static <V> TrustedListenableFutureTask<V>
create(java.lang.Runnable runnable, V result)
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>
create(java.util.concurrent.Callable<V> callable)
Creates aListenableFutureTask
that will upon running, execute the givenCallable
.void
run()
java.lang.String
toString()
-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture.TrustedFuture
addListener, cancel, get, get, isCancelled, isDone
-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
interruptTask, maybePropagateCancellation, set, setException, setFuture, trustedGetException, wasInterrupted
-
-
-
-
Field Detail
-
task
private TrustedListenableFutureTask.TrustedFutureInterruptibleTask task
-
-
Constructor Detail
-
TrustedListenableFutureTask
TrustedListenableFutureTask(java.util.concurrent.Callable<V> callable)
-
-
Method Detail
-
create
static <V> TrustedListenableFutureTask<V> create(java.util.concurrent.Callable<V> callable)
Creates aListenableFutureTask
that will upon running, execute the givenCallable
.- Parameters:
callable
- the callable task
-
create
static <V> TrustedListenableFutureTask<V> create(java.lang.Runnable runnable, @Nullable V result)
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 interfacejava.lang.Runnable
- Specified by:
run
in interfacejava.util.concurrent.RunnableFuture<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>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-