Package org.infinispan.util.concurrent
Class CompletableFutures
- java.lang.Object
-
- org.infinispan.util.concurrent.CompletableFutures
-
public class CompletableFutures extends Object
Utility methods connectingCompletableFuturefutures.- Since:
- 8.0
- Author:
- Dan Berindei
-
-
Field Summary
Fields Modifier and Type Field Description static CompletableFuture[]EMPTY_ARRAY
-
Constructor Summary
Constructors Constructor Description CompletableFutures()
-
Method Summary
-
-
-
Field Detail
-
EMPTY_ARRAY
public static final CompletableFuture[] EMPTY_ARRAY
-
-
Method Detail
-
completedEmptyMap
public static <K,V> CompletableFuture<Map<K,V>> completedEmptyMap()
-
completedNull
public static <T> CompletableFuture<T> completedNull()
-
completedTrue
public static CompletableFuture<Boolean> completedTrue()
-
completedFalse
public static CompletableFuture<Boolean> completedFalse()
-
composeTrue
public static <T> Function<T,CompletionStage<Boolean>> composeTrue()
-
composeFalse
public static <T> Function<T,CompletionStage<Boolean>> composeFalse()
-
sequence
public static <T> CompletableFuture<List<T>> sequence(List<CompletableFuture<T>> futures)
-
completedExceptionFuture
public static <T> CompletableFuture<T> completedExceptionFuture(Throwable ex)
-
await
public static boolean await(CompletableFuture<?> future, long time, TimeUnit unit) throws InterruptedException
It waits until theCompletableFutureis completed.It ignore if the
CompletableFutureis completed normally or exceptionally.- Parameters:
future- theCompletableFutureto test.time- the timeout.unit- the timeout unit.- Returns:
trueif completed,falseif timed out.- Throws:
InterruptedException- if interrupted while waiting.NullPointerException- iffutureorunitisnull.
-
await
public static <T> T await(CompletableFuture<T> future) throws ExecutionException, InterruptedException
Wait for a long time until theCompletableFutureis completed.- Type Parameters:
T- the return type.- Parameters:
future- theCompletableFuture.- Returns:
- the result value.
- Throws:
ExecutionException- if theCompletableFuturecompleted exceptionally.InterruptedException- if the current thread was interrupted while waiting.
-
asCompletionException
public static CompletionException asCompletionException(Throwable t)
-
rethrowException
public static void rethrowException(Throwable t)
-
toNullFunction
public static <T,R> Function<T,R> toNullFunction()
-
-