private static final class Futures.InCompletionOrderFuture<T> extends AbstractFuture<T>
AbstractFuture.Trusted<V>, AbstractFuture.TrustedFuture<V>
Modifier and Type | Field and Description |
---|---|
private Futures.InCompletionOrderState<T> |
state |
GENERATE_CANCELLATION_CAUSES
Modifier | Constructor and Description |
---|---|
private |
InCompletionOrderFuture(Futures.InCompletionOrderState<T> state) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterDone()
Callback method that is called exactly once after the future is completed.
|
boolean |
cancel(boolean interruptIfRunning) |
protected java.lang.String |
pendingToString()
Provide a human-readable explanation of why this future has not yet completed.
|
addListener, get, get, interruptTask, isCancelled, isDone, maybePropagateCancellationTo, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted
@CheckForNull private Futures.InCompletionOrderState<T> state
private InCompletionOrderFuture(Futures.InCompletionOrderState<T> state)
public boolean cancel(boolean interruptIfRunning)
AbstractFuture
If a cancellation attempt succeeds on a Future
that had previously been set asynchronously, then the cancellation will also be propagated to the delegate
Future
that was supplied in the setFuture
call.
Rather than override this method to perform additional cancellation work or cleanup,
subclasses should override AbstractFuture.afterDone()
, consulting AbstractFuture.isCancelled()
and AbstractFuture.wasInterrupted()
as necessary. This ensures that the work is done even if the future is
cancelled without a call to cancel
, such as by calling setFuture(cancelledFuture)
.
Beware of completing a future while holding a lock. Its listeners may do slow work or acquire other locks, risking deadlocks.
cancel
in interface java.util.concurrent.Future<T>
cancel
in class AbstractFuture<T>
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<T>
@CheckForNull protected java.lang.String pendingToString()
AbstractFuture
pendingToString
in class AbstractFuture<T>