java.lang.Object
io.lettuce.core.internal.Futures
public abstract class Futures extends Object
Utility methods for
Future handling. This class is part of the internal API and may change
without further notice.- Since:
- 5.1
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description static <V> voidadapt(Future<V> source, CompletableFuture<V> target)Adapt Netty'sFutureemitting a value result into aCompletableFuture.static CompletableFuture<Void>allOf(Collection<? extends CompletionStage<?>> stages)Create a compositeCompletableFutureis composed from the givenstages.static booleanawait(long timeout, TimeUnit unit, Future<?> future)Wait until future is complete or the supplied timeout is reached.static booleanawait(Duration timeout, Future<?> future)Wait until future is complete or the supplied timeout is reached.static booleanawaitAll(long timeout, TimeUnit unit, Future<?>... futures)Wait until futures are complete or the supplied timeout is reached.static booleanawaitAll(Duration timeout, Future<?>... futures)Wait until futures are complete or the supplied timeout is reached.static <T> TawaitOrCancel(RedisFuture<T> cmd, long timeout, TimeUnit unit)Wait until futures are complete or the supplied timeout is reached.static <T> CompletableFuture<T>failed(Throwable throwable)Create aCompletableFuturethat is completed exceptionally withthrowable.static <V> CompletionStage<V>toCompletionStage(Future<V> future)Adapt Netty'sChannelFutureemitting aVoidresult.
-
Method Details
-
allOf
Create a compositeCompletableFutureis composed from the givenstages.- Parameters:
stages- must not benull.- Returns:
- the composed
CompletableFuture. - Since:
- 5.1.1
-
failed
Create aCompletableFuturethat is completed exceptionally withthrowable.- Parameters:
throwable- must not benull.- Returns:
- the exceptionally completed
CompletableFuture.
-
toCompletionStage
Adapt Netty'sChannelFutureemitting aVoidresult.- Parameters:
future- theChannelFutureto adapt.- Returns:
- the
CompletableFuture. - Since:
- 6.0
-
adapt
Adapt Netty'sFutureemitting a value result into aCompletableFuture.- Parameters:
source- sourceFutureemitting signals.target- targetCompletableFuture.- Since:
- 6.0
-
await
Wait until future is complete or the supplied timeout is reached.- Parameters:
timeout- Maximum time to wait for futures to complete.future- Future to wait for.- Returns:
trueif future completes in time, otherwisefalse- Since:
- 6.0
-
await
Wait until future is complete or the supplied timeout is reached.- Parameters:
timeout- Maximum time to wait for futures to complete.unit- Unit of time for the timeout.future- Future to wait for.- Returns:
trueif future completes in time, otherwisefalse- Since:
- 6.0
-
awaitAll
Wait until futures are complete or the supplied timeout is reached.- Parameters:
timeout- Maximum time to wait for futures to complete.futures- Futures to wait for.- Returns:
trueif all futures complete in time, otherwisefalse- Since:
- 6.0
-
awaitAll
Wait until futures are complete or the supplied timeout is reached.- Parameters:
timeout- Maximum time to wait for futures to complete.unit- Unit of time for the timeout.futures- Futures to wait for.- Returns:
trueif all futures complete in time, otherwisefalse
-
awaitOrCancel
Wait until futures are complete or the supplied timeout is reached. Commands are canceled if the timeout is reached but the command is not finished.- Type Parameters:
T- Result type- Parameters:
cmd- Command to wait fortimeout- Maximum time to wait for futures to completeunit- Unit of time for the timeout- Returns:
- Result of the command.
- Since:
- 6.0
-