Class DelayedCompletableFuture<T>

  • Type Parameters:
    T - The result type
    All Implemented Interfaces:
    java.lang.Comparable<java.util.concurrent.Delayed>, java.util.concurrent.CompletionStage<T>, java.util.concurrent.Delayed, java.util.concurrent.Future<T>, java.util.concurrent.ScheduledFuture<T>

    public class DelayedCompletableFuture<T>
    extends java.util.concurrent.CompletableFuture<T>
    implements java.util.concurrent.ScheduledFuture<T>
    Specialized CompletableFuture used in combination with a scheduler.
    Since:
    4.0.0
    See Also:
    CompletableFuture, Delayed
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture

        java.util.concurrent.CompletableFuture.AsynchronousCompletionTask
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)  
      int compareTo​(java.util.concurrent.Delayed o)  
      long getDelay​(java.util.concurrent.TimeUnit unit)  
      static <E> DelayedCompletableFuture<E> make​(java.util.concurrent.ScheduledExecutorService executor, long delay, java.util.concurrent.TimeUnit unit, java.util.function.Function<? super DelayedCompletableFuture<E>,​? extends java.lang.Runnable> mapping)
      Creates a new DelayedCompletableFuture scheduled on the supplied executor.
      • Methods inherited from class java.util.concurrent.CompletableFuture

        acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, complete, completedFuture, completeExceptionally, exceptionally, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, obtrudeException, obtrudeValue, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.Future

        get, get, isCancelled, isDone
    • Method Detail

      • make

        @Nonnull
        public static <E> DelayedCompletableFuture<E> make​(@Nonnull
                                                           java.util.concurrent.ScheduledExecutorService executor,
                                                           long delay,
                                                           @Nonnull
                                                           java.util.concurrent.TimeUnit unit,
                                                           @Nonnull
                                                           java.util.function.Function<? super DelayedCompletableFuture<E>,​? extends java.lang.Runnable> mapping)
        Creates a new DelayedCompletableFuture scheduled on the supplied executor.
        Type Parameters:
        E - The result type of the scheduled task
        Parameters:
        executor - The ScheduledExecutorService to use for scheduling
        delay - The delay of the task
        unit - Conversion TimeUnit for the delay
        mapping - Conversion function which calls CompletableFuture.complete(Object) of the future it receives
        Returns:
        DelayedCompletableFuture for the specified runnable
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<T>
        Overrides:
        cancel in class java.util.concurrent.CompletableFuture<T>
      • getDelay

        public long getDelay​(@Nonnull
                             java.util.concurrent.TimeUnit unit)
        Specified by:
        getDelay in interface java.util.concurrent.Delayed
      • compareTo

        public int compareTo​(@Nonnull
                             java.util.concurrent.Delayed o)
        Specified by:
        compareTo in interface java.lang.Comparable<T>