Package org.infinispan.util.concurrent
Class CompletableFutures
- java.lang.Object
-
- org.infinispan.util.concurrent.CompletableFutures
-
public class CompletableFutures extends java.lang.ObjectUtility methods connectingCompletableFuturefutures.- Since:
- 8.0
- Author:
- Dan Berindei
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.concurrent.CompletableFuture[]EMPTY_ARRAY
-
Constructor Summary
Constructors Constructor Description CompletableFutures()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.CompletionExceptionasCompletionException(java.lang.Throwable t)static booleanawait(java.util.concurrent.CompletableFuture<?> future, long time, java.util.concurrent.TimeUnit unit)It waits until theCompletableFutureis completed.static <T> Tawait(java.util.concurrent.CompletableFuture<T> future)Wait for a long time until theCompletableFutureis completed.static java.util.concurrent.CompletionStage<java.lang.Boolean>booleanStage(boolean trueOrFalse)static <K,V>
java.util.concurrent.CompletableFuture<java.util.Map<K,V>>completedEmptyMap()static <T> java.util.concurrent.CompletableFuture<T>completedExceptionFuture(java.lang.Throwable ex)static java.util.concurrent.CompletableFuture<java.lang.Boolean>completedFalse()static <T> java.util.concurrent.CompletableFuture<T>completedNull()static java.util.concurrent.CompletableFuture<java.lang.Boolean>completedTrue()static <T> java.util.function.Function<T,java.util.concurrent.CompletionStage<java.lang.Boolean>>composeFalse()static <T,R>
java.util.function.Function<T,java.util.concurrent.CompletionStage<R>>composeNull()static <T> java.util.function.Function<T,java.util.concurrent.CompletionStage<java.lang.Boolean>>composeTrue()static java.lang.ThrowableextractException(java.lang.Throwable t)static voidrethrowException(java.lang.Throwable t)static <T> java.util.concurrent.CompletableFuture<java.util.List<T>>sequence(java.util.List<java.util.concurrent.CompletableFuture<T>> futures)static <T,R>
java.util.function.Function<T,R>toNullFunction()static booleanuncheckedAwait(java.util.concurrent.CompletableFuture<?> future, long time, java.util.concurrent.TimeUnit unit)Same asawait(CompletableFuture, long, TimeUnit)but wraps checked exceptions inCacheExceptionstatic <T> TuncheckedAwait(java.util.concurrent.CompletableFuture<T> future)Same asawait(CompletableFuture)but wraps checked exceptions inCacheException
-
-
-
Method Detail
-
completedEmptyMap
public static <K,V> java.util.concurrent.CompletableFuture<java.util.Map<K,V>> completedEmptyMap()
-
completedNull
public static <T> java.util.concurrent.CompletableFuture<T> completedNull()
-
completedTrue
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedTrue()
-
completedFalse
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedFalse()
-
composeTrue
public static <T> java.util.function.Function<T,java.util.concurrent.CompletionStage<java.lang.Boolean>> composeTrue()
-
composeFalse
public static <T> java.util.function.Function<T,java.util.concurrent.CompletionStage<java.lang.Boolean>> composeFalse()
-
composeNull
public static <T,R> java.util.function.Function<T,java.util.concurrent.CompletionStage<R>> composeNull()
-
booleanStage
public static java.util.concurrent.CompletionStage<java.lang.Boolean> booleanStage(boolean trueOrFalse)
-
sequence
public static <T> java.util.concurrent.CompletableFuture<java.util.List<T>> sequence(java.util.List<java.util.concurrent.CompletableFuture<T>> futures)
-
completedExceptionFuture
public static <T> java.util.concurrent.CompletableFuture<T> completedExceptionFuture(java.lang.Throwable ex)
-
await
public static boolean await(java.util.concurrent.CompletableFuture<?> future, long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionIt 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:
java.lang.InterruptedException- if interrupted while waiting.java.lang.NullPointerException- iffutureorunitisnull.
-
uncheckedAwait
public static boolean uncheckedAwait(java.util.concurrent.CompletableFuture<?> future, long time, java.util.concurrent.TimeUnit unit)Same asawait(CompletableFuture, long, TimeUnit)but wraps checked exceptions inCacheException- Parameters:
future- theCompletableFutureto test.time- the timeout.unit- the timeout unit.- Returns:
trueif completed,falseif timed out.- Throws:
java.lang.NullPointerException- iffutureorunitisnull.
-
await
public static <T> T await(java.util.concurrent.CompletableFuture<T> future) throws java.util.concurrent.ExecutionException, java.lang.InterruptedExceptionWait for a long time until theCompletableFutureis completed.- Type Parameters:
T- the return type.- Parameters:
future- theCompletableFuture.- Returns:
- the result value.
- Throws:
java.util.concurrent.ExecutionException- if theCompletableFuturecompleted exceptionally.java.lang.InterruptedException- if the current thread was interrupted while waiting.
-
uncheckedAwait
public static <T> T uncheckedAwait(java.util.concurrent.CompletableFuture<T> future)
Same asawait(CompletableFuture)but wraps checked exceptions inCacheException- Type Parameters:
T- the return type.- Parameters:
future- theCompletableFuture.- Returns:
- the result value.
-
asCompletionException
public static java.util.concurrent.CompletionException asCompletionException(java.lang.Throwable t)
-
rethrowException
public static void rethrowException(java.lang.Throwable t)
-
extractException
public static java.lang.Throwable extractException(java.lang.Throwable t)
-
toNullFunction
public static <T,R> java.util.function.Function<T,R> toNullFunction()
-
-