-
- Type Parameters:
T
- payload type
- All Known Subinterfaces:
Single<T>
- All Known Implementing Classes:
CompletionAwaitable
,CompletionSingle
public interface Awaitable<T>
Makes intentional blocking when waiting forCompletableFuture
more convenient withawait()
andawait(long, java.util.concurrent.TimeUnit)
methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default T
await()
Block until future is completed, throws only unchecked exceptions.default T
await(long timeout, TimeUnit unit)
Block until future is completed, throws only unchecked exceptions.default T
await(Duration duration)
Block until future is completed, throws only unchecked exceptions.CompletableFuture<T>
toCompletableFuture()
Returns aCompletableFuture
maintaining the same completion properties as this stage.
-
-
-
Method Detail
-
toCompletableFuture
CompletableFuture<T> toCompletableFuture()
Returns aCompletableFuture
maintaining the same completion properties as this stage. If this stage is already a CompletableFuture, this method may return this stage itself. Otherwise, invocation of this method may be equivalent in effect tothenApply(x -> x)
, but returning an instance of typeCompletableFuture
.- Returns:
- the CompletableFuture
-
await
default T await()
Block until future is completed, throws only unchecked exceptions.- Returns:
- T payload type
- Throws:
CancellationException
- if the computation was cancelledCompletionException
- if this future completed
-
await
default T await(long timeout, TimeUnit unit)
Block until future is completed, throws only unchecked exceptions.- Parameters:
timeout
- the maximum time to waitunit
- the time unit of the timeout argument- Returns:
- the result value
- Throws:
CancellationException
- if this future was cancelledCompletionException
- if this future completed exceptionally, was interrupted while waiting or the wait timed out
-
await
default T await(Duration duration)
Block until future is completed, throws only unchecked exceptions.- Parameters:
duration
- the maximum time to wait- Returns:
- the result value
- Throws:
CancellationException
- if this future was cancelledCompletionException
- if this future completed exceptionally, was interrupted while waiting or the wait timed out
-
-