Class DelayedCompletableFuture<T>
- java.lang.Object
-
- java.util.concurrent.CompletableFuture<T>
-
- net.dv8tion.jda.api.utils.concurrent.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>SpecializedCompletableFutureused in combination with a scheduler.- Since:
- 4.0.0
- See Also:
CompletableFuture,Delayed
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)intcompareTo(java.util.concurrent.Delayed o)longgetDelay(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
-
-
-
-
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- TheScheduledExecutorServiceto use for schedulingdelay- The delay of the taskunit- ConversionTimeUnitfor the delaymapping- Conversion function which callsCompletableFuture.complete(Object)of the future it receives- Returns:
- DelayedCompletableFuture for the specified runnable
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
getDelay
public long getDelay(@Nonnull java.util.concurrent.TimeUnit unit)- Specified by:
getDelayin interfacejava.util.concurrent.Delayed
-
compareTo
public int compareTo(@Nonnull java.util.concurrent.Delayed o)- Specified by:
compareToin interfacejava.lang.Comparable<T>
-
-