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>
public class DelayedCompletableFuture<T> extends CompletableFuture<T> implements ScheduledFuture<T>
SpecializedCompletableFuture
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
CompletableFuture.AsynchronousCompletionTask
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
int
compareTo(Delayed o)
long
getDelay(TimeUnit unit)
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 Detail
-
make
@Nonnull 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)
-
compareTo
public int compareTo(@Nonnull Delayed o)
- Specified by:
compareTo
in interfaceComparable<T>
-
-