Package org.infinispan.util.concurrent
Class CompletableFutures
- java.lang.Object
-
- org.infinispan.util.concurrent.CompletableFutures
-
public class CompletableFutures extends Object
Utility methods connectingCompletableFuture
futures.- 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 theCompletableFuture
is completed.It ignore if the
CompletableFuture
is completed normally or exceptionally.- Parameters:
future
- theCompletableFuture
to test.time
- the timeout.unit
- the timeout unit.- Returns:
true
if completed,false
if timed out.- Throws:
InterruptedException
- if interrupted while waiting.NullPointerException
- iffuture
orunit
isnull
.
-
await
public static <T> T await(CompletableFuture<T> future) throws ExecutionException, InterruptedException
Wait for a long time until theCompletableFuture
is completed.- Type Parameters:
T
- the return type.- Parameters:
future
- theCompletableFuture
.- Returns:
- the result value.
- Throws:
ExecutionException
- if theCompletableFuture
completed 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()
-
-