Class Futures.InCompletionOrderFuture<T>

  • All Implemented Interfaces:
    ListenableFuture<T>, java.util.concurrent.Future<T>
    Enclosing class:
    Futures

    private static final class Futures.InCompletionOrderFuture<T>
    extends AbstractFuture<T>
    • Method Detail

      • 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 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.

        Specified by:
        cancel in interface java.util.concurrent.Future<T>
        Overrides:
        cancel in class AbstractFuture<T>
      • 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 class AbstractFuture<T>
      • pendingToString

        protected java.lang.String pendingToString()
        Description copied from class: AbstractFuture
        Provide a human-readable explanation of why this future has not yet completed.
        Overrides:
        pendingToString in class AbstractFuture<T>
        Returns:
        null if an explanation cannot be provided (e.g. because the future is done).