Package io.lettuce.core.internal
Class Futures
- java.lang.Object
-
- io.lettuce.core.internal.Futures
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <V> void
adapt(Future<V> source, CompletableFuture<V> target)
Adapt Netty'sFuture
emitting a value result into aCompletableFuture
.static CompletableFuture<Void>
allOf(Collection<? extends CompletionStage<?>> stages)
Create a compositeCompletableFuture
is composed from the givenstages
.static boolean
await(long timeout, TimeUnit unit, Future<?> future)
Wait until future is complete or the supplied timeout is reached.static boolean
await(Duration timeout, Future<?> future)
Wait until future is complete or the supplied timeout is reached.static boolean
awaitAll(long timeout, TimeUnit unit, Future<?>... futures)
Wait until futures are complete or the supplied timeout is reached.static boolean
awaitAll(Duration timeout, Future<?>... futures)
Wait until futures are complete or the supplied timeout is reached.static <T> T
awaitOrCancel(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 aCompletableFuture
that is completed exceptionally withthrowable
.static <V> CompletionStage<V>
toCompletionStage(Future<V> future)
Adapt Netty'sChannelFuture
emitting aVoid
result.
-
-
-
Method Detail
-
allOf
public static CompletableFuture<Void> allOf(Collection<? extends CompletionStage<?>> stages)
Create a compositeCompletableFuture
is composed from the givenstages
.- Parameters:
stages
- must not benull
.- Returns:
- the composed
CompletableFuture
. - Since:
- 5.1.1
-
failed
public static <T> CompletableFuture<T> failed(Throwable throwable)
Create aCompletableFuture
that is completed exceptionally withthrowable
.- Parameters:
throwable
- must not benull
.- Returns:
- the exceptionally completed
CompletableFuture
.
-
toCompletionStage
public static <V> CompletionStage<V> toCompletionStage(Future<V> future)
Adapt Netty'sChannelFuture
emitting aVoid
result.- Parameters:
future
- theChannelFuture
to adapt.- Returns:
- the
CompletableFuture
. - Since:
- 6.0
-
adapt
public static <V> void adapt(Future<V> source, CompletableFuture<V> target)
Adapt Netty'sFuture
emitting a value result into aCompletableFuture
.- Parameters:
source
- sourceFuture
emitting signals.target
- targetCompletableFuture
.- Since:
- 6.0
-
await
public static boolean await(Duration timeout, Future<?> future)
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:
true
if future completes in time, otherwisefalse
- Since:
- 6.0
-
await
public static boolean await(long timeout, TimeUnit unit, Future<?> future)
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:
true
if future completes in time, otherwisefalse
- Since:
- 6.0
-
awaitAll
public static boolean awaitAll(Duration timeout, Future<?>... futures)
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:
true
if all futures complete in time, otherwisefalse
- Since:
- 6.0
-
awaitAll
public static boolean awaitAll(long timeout, TimeUnit unit, Future<?>... futures)
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:
true
if all futures complete in time, otherwisefalse
-
awaitOrCancel
public static <T> T awaitOrCancel(RedisFuture<T> cmd, long timeout, TimeUnit unit)
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
-
-