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>
SpecializedCompletableFuture
used 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 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
-
-
-
-
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
- TheScheduledExecutorService
to use for schedulingdelay
- The delay of the taskunit
- ConversionTimeUnit
for 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:
getDelay
in interfacejava.util.concurrent.Delayed
-
compareTo
public int compareTo(@Nonnull java.util.concurrent.Delayed o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<T>
-
-