Interface AsyncFuture<T>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  AsyncFuture.Status  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      AsyncFuture<T> addListener​(AsyncFutureListener<T> listener)
      Adds the specified listener to this future.
      AsyncFuture<T> addListener​(AsyncPromise<T> listener)
      Adds the specified future as a listener to this future.
      AsyncFuture<T> await()
      Waits for this future to be completed.
      boolean await​(long timeout, java.util.concurrent.TimeUnit unit)
      Waits for this future to be completed within the specified time limit.
      AsyncFuture<T> awaitUninterruptibly()
      Waits for this future to be completed without interruption.
      boolean awaitUninterruptibly​(long timeout, java.util.concurrent.TimeUnit unit)
      Waits for this future to be completed within the specified time limit without interruption.
      static <T> AsyncPromise<T> cancelled()
      Obtain an instance of an AsyncFuture which is in the Cancelled state.
      static <T> AsyncFuture<java.util.List<T>> collect​(java.util.List<AsyncFuture<java.util.List<T>>> futuresList, boolean cancellable)  
      static <T> AsyncPromise<T> deferred​(boolean cancellable)
      Create a new default deferred future.
      static <T> AsyncPromise<T> failed​(java.lang.Throwable exception)
      Create a new failed future.
      java.lang.Throwable getCause()
      Returns the cause of the failed I/O operation if the I/O operation has failed.
      T getNow()
      Non-blocking variant of Future.get()
      static AsyncFuture.Status getStatus​(AsyncFuture<?> future)  
      boolean isSuccess()
      Returns true if and only if the I/O operation was completed successfully.
      static <T> AsyncFuture<T> of​(AsyncFuture<T> stage, boolean cancellable)  
      static <T> AsyncFuture<T> of​(java.util.concurrent.CompletionStage<T> stage, boolean cancellable)  
      static <T,​V extends T>
      AsyncPromise<T>
      success​(V value)
      Create a new success future.
      • Methods inherited from interface java.util.concurrent.CompletionStage

        acceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, exceptionally, handle, handleAsync, handleAsync, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsync
      • Methods inherited from interface java.util.concurrent.Future

        cancel, get, get, isCancelled, isDone
    • Field Detail

    • Method Detail

      • 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

        java.lang.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 java.lang.InterruptedException
        Waits for this future to be completed.
        Throws:
        java.lang.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,
                      java.util.concurrent.TimeUnit unit)
               throws java.lang.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:
        java.lang.InterruptedException - if the current thread was interrupted
      • awaitUninterruptibly

        boolean awaitUninterruptibly​(long timeout,
                                     java.util.concurrent.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
                                     java.util.concurrent.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
                                          java.lang.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<java.util.List<T>> collect​(java.util.List<AsyncFuture<java.util.List<T>>> futuresList,
                                                          boolean cancellable)