-
- 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 forCompletableFuturemore 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 Tawait()Block until future is completed, throws only unchecked exceptions.default Tawait(long timeout, TimeUnit unit)Block until future is completed, throws only unchecked exceptions.default Tawait(Duration duration)Block until future is completed, throws only unchecked exceptions.CompletableFuture<T>toCompletableFuture()Returns aCompletableFuturemaintaining the same completion properties as this stage.
-
-
-
Method Detail
-
toCompletableFuture
CompletableFuture<T> toCompletableFuture()
Returns aCompletableFuturemaintaining 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
-
-