Class TimeoutFuture<V>

  • All Implemented Interfaces:
    ListenableFuture<V>, java.util.concurrent.Future<V>

    @GwtIncompatible
    final class TimeoutFuture<V>
    extends AbstractFuture.TrustedFuture<V>
    Implementation of Futures#withTimeout.

    Future that delegates to another but will finish early (via a TimeoutException wrapped in an ExecutionException) if the specified duration expires. The delegate future is interrupted and cancelled if it times out.

    • Field Detail

      • timer

        @Nullable
        private java.util.concurrent.Future<?> timer
    • Method Detail

      • create

        static <V> ListenableFuture<V> create​(ListenableFuture<V> delegate,
                                              long time,
                                              java.util.concurrent.TimeUnit unit,
                                              java.util.concurrent.ScheduledExecutorService scheduledExecutor)
      • 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<V>