- 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 for
CompletableFuture
more convenient with await()
and await(long, java.util.concurrent.TimeUnit)
methods.-
Method Summary
Modifier and TypeMethodDescriptiondefault T
await()
Block until future is completed, throws only unchecked exceptions.default T
Deprecated.default T
Block until future is completed, throws only unchecked exceptions.Returns aCompletableFuture
maintaining the same completion properties as this stage.
-
Method Details
-
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
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
Deprecated.useawait(Duration)
insteadBlock 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
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
-
await(Duration)
instead