Class Futures.InCompletionOrderFuture<T>
- All Implemented Interfaces:
ListenableFuture<T>
,Future<T>
- Enclosing class:
Futures
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.util.concurrent.AbstractFuture
AbstractFuture.Trusted<V>, AbstractFuture.TrustedFuture<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
ConstructorsModifierConstructorDescriptionprivate
-
Method Summary
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
addListener, get, get, interruptTask, isCancelled, isDone, 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
exceptionNow, resultNow, state
-
Field Details
-
state
-
-
Constructor Details
-
InCompletionOrderFuture
-
-
Method Details
-
cancel
public boolean cancel(boolean interruptIfRunning) Description copied from class:AbstractFuture
If a cancellation attempt succeeds on a
Future
that had previously been set asynchronously, then the cancellation will also be propagated to the delegateFuture
that was supplied in thesetFuture
call.Rather than override this method to perform additional cancellation work or cleanup, subclasses should override
AbstractFuture.afterDone()
, consultingAbstractFuture.isCancelled()
andAbstractFuture.wasInterrupted()
as necessary. This ensures that the work is done even if the future is cancelled without a call tocancel
, such as by callingsetFuture(cancelledFuture)
.Beware of completing a future while holding a lock. Its listeners may do slow work or acquire other locks, risking deadlocks.
-
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<T>
-
pendingToString
Description copied from class:AbstractFuture
Provide a human-readable explanation of why this future has not yet completed.- Overrides:
pendingToString
in classAbstractFuture<T>
- Returns:
- null if an explanation cannot be provided (e.g. because the future is done).
-