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:
Comparable<Delayed>
,CompletionStage<T>
,Delayed
,Future<T>
,ScheduledFuture<T>
Specialized
CompletableFuture
used in combination with a scheduler.- Since:
- 4.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask
-
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel
(boolean mayInterruptIfRunning) int
long
static <E> DelayedCompletableFuture
<E> make
(ScheduledExecutorService executor, long delay, TimeUnit unit, Function<? super DelayedCompletableFuture<E>, ? extends 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 Details
-
make
@Nonnull @CheckReturnValue public static <E> DelayedCompletableFuture<E> make(@Nonnull ScheduledExecutorService executor, long delay, @Nonnull TimeUnit unit, @Nonnull Function<? super DelayedCompletableFuture<E>, ? extends 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
-
compareTo
- Specified by:
compareTo
in interfaceComparable<T>
-