Interface Awaitable<T>

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 Type
    Method
    Description
    default T
    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.
    Returns a CompletableFuture maintaining the same completion properties as this stage.
  • Method Details

    • toCompletableFuture

      CompletableFuture<T> toCompletableFuture()
      Returns a CompletableFuture 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 to thenApply(x -> x), but returning an instance of type CompletableFuture.
      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 cancelled
      CompletionException - 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 wait
      unit - the time unit of the timeout argument
      Returns:
      the result value
      Throws:
      CancellationException - if this future was cancelled
      CompletionException - 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 cancelled
      CompletionException - if this future completed exceptionally, was interrupted while waiting or the wait timed out