Interface Future<V>

All Superinterfaces:
Future<V>
All Known Subinterfaces:
ChannelFuture, ChannelGroupFuture, ChannelProgressiveFuture, ChannelProgressivePromise, ChannelPromise, ProgressiveFuture<V>, ProgressivePromise<V>, Promise<V>, ScheduledFuture<V>
All Known Implementing Classes:
AbstractBootstrap.PendingRegistrationPromise, AbstractChannel.CloseFuture, AbstractFuture, CompleteChannelFuture, CompleteFuture, DefaultChannelGroupFuture, DefaultChannelProgressivePromise, DefaultChannelPromise, DefaultProgressivePromise, DefaultPromise, DelegatingChannelPromiseNotifier, FailedChannelFuture, FailedFuture, Http2CodecUtil.SimpleChannelPromiseAggregator, ImmediateEventExecutor.ImmediateProgressivePromise, ImmediateEventExecutor.ImmediatePromise, PromiseTask, ProxyHandler.LazyChannelPromise, ScheduledFutureTask, SslHandler.LazyChannelPromise, SucceededChannelFuture, SucceededFuture, UnorderedThreadPoolEventExecutor.RunnableScheduledFutureTask, VoidChannelGroupFuture, VoidChannelPromise

public interface Future<V> extends Future<V>
The result of an asynchronous operation.
  • Method Details

    • 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

      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 InterruptedException
      Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
      Throws:
      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 InterruptedException
      Waits for this future to be completed.
      Throws:
      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, 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
    • await

      boolean await(long timeoutMillis) 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
    • 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 Future<V>