Interface AsyncFuture<T>

All Superinterfaces:
CompletionStage<T>, Future<T>
All Known Subinterfaces:
AsyncPromise<T>, RunnableScheduledFuture<V>, ScheduledFuture<V>
All Known Implementing Classes:
AbstractAsyncFuture, CancelledAsyncFuture, DefaultAsyncFuture, DefaultAsyncFutureTask, DefaultCollectingAsyncFuture, FailedAsyncFuture, SuccessAsyncFuture

public interface AsyncFuture<T> extends Future<T>, CompletionStage<T>
A Future which has very netty-style semantics where AsyncFutureListener can be added to the future to be executed upon condition of Success or Failure has been satisfied. See DefaultAsyncFuture. See also DefaultAsyncFutureTask
  • Field Details

  • Method Details

    • getNow

      T getNow()
      Non-blocking variant of Future.get()
      Returns:
      value or null
    • isSuccess

      boolean isSuccess()
      Returns true if and only if the I/O operation was completed successfully.
    • getCause

      Throwable getCause()
      Returns the cause of the failed I/O operation if the I/O operation has failed.
      Returns:
      the cause of the failure. null if succeeded or this future is not completed yet.
    • addListener

      @Nonnull AsyncFuture<T> addListener(AsyncFutureListener<T> listener)
      Adds the specified listener to this future. The specified listener is notified when this future is done. If this future is already completed, the specified listener is notified immediately.
      Returns:
      this to permit chaining of operations.
    • addListener

      @Nonnull AsyncFuture<T> addListener(AsyncPromise<T> listener)
      Adds the specified future as a listener to this future. The specified future is notified when this future is done. If this future is already completed, the specified future is notified immediately.
      Parameters:
      listener -
      Returns:
      this to permit chaining of operations.
    • await

      @Nonnull AsyncFuture<T> await() throws InterruptedException
      Waits for this future to be completed.
      Throws:
      InterruptedException - if the current thread was interrupted
    • awaitUninterruptibly

      @Nonnull AsyncFuture<T> awaitUninterruptibly()
      Waits for this future to be completed without interruption. This method catches an InterruptedException and discards it silently.
    • await

      boolean await(long timeout, TimeUnit unit) throws InterruptedException
      Waits for this future to be completed within the specified time limit.
      Returns:
      true if and only if the future was completed within the specified time limit
      Throws:
      InterruptedException - if the current thread was interrupted
    • awaitUninterruptibly

      boolean awaitUninterruptibly(long timeout, TimeUnit unit)
      Waits for this future to be completed within the specified time limit without interruption. This method catches an InterruptedException and discards it silently.
      Returns:
      true if and only if the future was completed within the specified time limit
    • of

      static <T> AsyncFuture<T> of(@Nonnull AsyncFuture<T> stage, boolean cancellable)
    • of

      static <T> AsyncFuture<T> of(@Nonnull CompletionStage<T> stage, boolean cancellable)
    • cancelled

      static <T> AsyncPromise<T> cancelled()
      Obtain an instance of an AsyncFuture which is in the Cancelled state.
      Type Parameters:
      T - any type.
      Returns:
      Cancelled future.
    • deferred

      static <T> AsyncPromise<T> deferred(boolean cancellable)
      Create a new default deferred future.
      Type Parameters:
      T - Type of the future.
      Parameters:
      cancellable - true if cancellable.
      Returns:
      new deferred async future.
    • failed

      static <T> AsyncPromise<T> failed(@Nonnull Throwable exception)
      Create a new failed future. These futures are already in the Done state.
      Type Parameters:
      T - Type of the future.
      Parameters:
      exception - exception.
      Returns:
      new failed async future.
    • success

      static <T, V extends T> AsyncPromise<T> success(V value)
      Create a new success future. These futures are already in the Done state.
      Type Parameters:
      T - Type of the value.
      Parameters:
      value - value of future.
      Returns:
      new success async future.
    • collect

      static <T> AsyncFuture<List<T>> collect(List<AsyncFuture<List<T>>> futuresList, boolean cancellable)
    • getStatus

      static AsyncFuture.Status getStatus(AsyncFuture<?> future)