Interface Future<V>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Future<V> addListener​(GenericFutureListener<? extends Future<? super V>> listener)
      Adds the specified listener to this future.
      Future<V> addListeners​(GenericFutureListener<? extends Future<? super V>>... listeners)
      Adds the specified listeners to this future.
      Future<V> await()
      Waits for this future to be completed.
      boolean await​(long timeoutMillis)
      Waits for this future to be completed within the specified time limit.
      boolean await​(long timeout, java.util.concurrent.TimeUnit unit)
      Waits for this future to be completed within the specified time limit.
      Future<V> awaitUninterruptibly()
      Waits for this future to be completed without interruption.
      boolean awaitUninterruptibly​(long timeoutMillis)
      Waits for this future to be completed within the specified time limit 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.
      boolean cancel​(boolean mayInterruptIfRunning)
      If the cancellation was successful it will fail the future with a CancellationException.
      java.lang.Throwable cause()
      Returns the cause of the failed I/O operation if the I/O operation has failed.
      V getNow()
      Return the result without blocking.
      boolean isCancellable()
      returns true if and only if the operation can be cancelled via cancel(boolean).
      boolean isSuccess()
      Returns true if and only if the I/O operation was completed successfully.
      Future<V> removeListener​(GenericFutureListener<? extends Future<? super V>> listener)
      Removes the first occurrence of the specified listener from this future.
      Future<V> removeListeners​(GenericFutureListener<? extends Future<? super V>>... listeners)
      Removes the first occurrence for each of the listeners from this future.
      Future<V> sync()
      Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
      Future<V> syncUninterruptibly()
      Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
      • Methods inherited from interface java.util.concurrent.Future

        get, get, isCancelled, isDone
    • Method Detail

      • isSuccess

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

        boolean isCancellable()
        returns true if and only if the operation can be cancelled via cancel(boolean).
      • cause

        java.lang.Throwable cause()
        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

        Future<V> addListener​(GenericFutureListener<? extends Future<? super V>> 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.
      • addListeners

        Future<V> addListeners​(GenericFutureListener<? extends Future<? super V>>... listeners)
        Adds the specified listeners to this future. The specified listeners are notified when this future is done. If this future is already completed, the specified listeners are notified immediately.
      • removeListener

        Future<V> removeListener​(GenericFutureListener<? extends Future<? super V>> listener)
        Removes the first occurrence of the specified listener from this future. The specified listener is no longer notified when this future is done. If the specified listener is not associated with this future, this method does nothing and returns silently.
      • removeListeners

        Future<V> removeListeners​(GenericFutureListener<? extends Future<? super V>>... listeners)
        Removes the first occurrence for each of the listeners from this future. The specified listeners are no longer notified when this future is done. If the specified listeners are not associated with this future, this method does nothing and returns silently.
      • sync

        Future<V> sync()
                throws java.lang.InterruptedException
        Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
        Throws:
        java.lang.InterruptedException
      • syncUninterruptibly

        Future<V> syncUninterruptibly()
        Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
      • await

        Future<V> await()
                 throws java.lang.InterruptedException
        Waits for this future to be completed.
        Throws:
        java.lang.InterruptedException - if the current thread was interrupted
      • awaitUninterruptibly

        Future<V> 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
      • await

        boolean await​(long timeoutMillis)
               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
      • awaitUninterruptibly

        boolean awaitUninterruptibly​(long timeoutMillis)
        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
      • getNow

        V getNow()
        Return the result without blocking. If the future is not done yet this will return null.

        As it is possible that a null value is used to mark the future as successful you also need to check if the future is really done with Future.isDone() and not rely on the returned null value.

      • cancel

        boolean cancel​(boolean mayInterruptIfRunning)
        If the cancellation was successful it will fail the future with a CancellationException.
        Specified by:
        cancel in interface java.util.concurrent.Future<V>