Contents
Class CompletableFutureUtil
java.lang.Object
com.hypixel.hytale.common.util.CompletableFutureUtil
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFuture<T> _catch(CompletableFuture<T> future) static <T> CompletableFuture<T> Returns a new CompletableFuture that has already been canceled.static booleanisCanceled(Throwable throwable) static voidjoinWithProgress(List<CompletableFuture<?>> list, CompletableFutureUtil.ProgressConsumer callback, int millisSleep, int millisProgress) Accepts a list ofCompletableFutureand waits for them all to complete, giving progress reports every millisProgress milliseconds, with the progress reports going to the ProgressConsumer passed as the argument to this method.static <T> CompletableFuture<T> whenComplete(CompletableFuture<T> future, CompletableFuture<T> callee)
-
Field Details
-
fn
-
-
Constructor Details
-
CompletableFutureUtil
public CompletableFutureUtil()
-
-
Method Details
-
whenComplete
@Nonnull public static <T> CompletableFuture<T> whenComplete(@Nonnull CompletableFuture<T> future, @Nonnull CompletableFuture<T> callee) -
isCanceled
-
_catch
-
completionCanceled
Returns a new CompletableFuture that has already been canceled. Useful for ending a chain of prebuilt futures.- Type Parameters:
T- The type of the CompletableFuture.- Returns:
- A CompletableFuture that has been canceled.
-
joinWithProgress
public static void joinWithProgress(@Nonnull List<CompletableFuture<?>> list, @Nonnull CompletableFutureUtil.ProgressConsumer callback, int millisSleep, int millisProgress) throws InterruptedException Accepts a list ofCompletableFutureand waits for them all to complete, giving progress reports every millisProgress milliseconds, with the progress reports going to the ProgressConsumer passed as the argument to this method. The current thread will be blocked until all CompletableFutures have completed, with them being checked for completion every millisTest milliseconds.- Parameters:
list- The list of CompletableFutures to wait oncallback- The target of the progress, which will be given doubles ranging from 0 to 1 as well as the current number of operations completed and the final number of operations. SeeCompletableFutureUtil.ProgressConsumer.accept(double, int, int)for more information.millisSleep- The number of milliseconds the thread should sleep for between checkingmillisProgress- The number of milliseconds between progress reports- Throws:
InterruptedException- If the thread is interrupted
-