Class VoidChannelPromise

java.lang.Object
io.netty.util.concurrent.AbstractFuture<java.lang.Void>
io.netty.channel.VoidChannelPromise
All Implemented Interfaces:
ChannelFuture, ChannelPromise, Future<java.lang.Void>, Promise<java.lang.Void>, java.util.concurrent.Future<java.lang.Void>

@UnstableApi public final class VoidChannelPromise extends AbstractFuture<java.lang.Void> implements ChannelPromise
  • Field Details

  • Constructor Details

    • VoidChannelPromise

      public VoidChannelPromise(Channel channel, boolean fireException)
      Creates a new instance.
      Parameters:
      channel - the Channel associated with this future
  • Method Details

    • addListener

      public VoidChannelPromise addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
      Description copied from interface: Future
      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.
      Specified by:
      addListener in interface ChannelFuture
      Specified by:
      addListener in interface ChannelPromise
      Specified by:
      addListener in interface Future<java.lang.Void>
      Specified by:
      addListener in interface Promise<java.lang.Void>
    • addListeners

      public VoidChannelPromise addListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
      Description copied from interface: Future
      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.
      Specified by:
      addListeners in interface ChannelFuture
      Specified by:
      addListeners in interface ChannelPromise
      Specified by:
      addListeners in interface Future<java.lang.Void>
      Specified by:
      addListeners in interface Promise<java.lang.Void>
    • removeListener

      public VoidChannelPromise removeListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
      Description copied from interface: Future
      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.
      Specified by:
      removeListener in interface ChannelFuture
      Specified by:
      removeListener in interface ChannelPromise
      Specified by:
      removeListener in interface Future<java.lang.Void>
      Specified by:
      removeListener in interface Promise<java.lang.Void>
    • removeListeners

      public VoidChannelPromise removeListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
      Description copied from interface: Future
      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.
      Specified by:
      removeListeners in interface ChannelFuture
      Specified by:
      removeListeners in interface ChannelPromise
      Specified by:
      removeListeners in interface Future<java.lang.Void>
      Specified by:
      removeListeners in interface Promise<java.lang.Void>
    • await

      public VoidChannelPromise await() throws java.lang.InterruptedException
      Description copied from interface: Future
      Waits for this future to be completed.
      Specified by:
      await in interface ChannelFuture
      Specified by:
      await in interface ChannelPromise
      Specified by:
      await in interface Future<java.lang.Void>
      Specified by:
      await in interface Promise<java.lang.Void>
      Throws:
      java.lang.InterruptedException - if the current thread was interrupted
    • await

      public boolean await(long timeout, java.util.concurrent.TimeUnit unit)
      Description copied from interface: Future
      Waits for this future to be completed within the specified time limit.
      Specified by:
      await in interface Future<java.lang.Void>
      Returns:
      true if and only if the future was completed within the specified time limit
    • await

      public boolean await(long timeoutMillis)
      Description copied from interface: Future
      Waits for this future to be completed within the specified time limit.
      Specified by:
      await in interface Future<java.lang.Void>
      Returns:
      true if and only if the future was completed within the specified time limit
    • awaitUninterruptibly

      public VoidChannelPromise awaitUninterruptibly()
      Description copied from interface: Future
      Waits for this future to be completed without interruption. This method catches an InterruptedException and discards it silently.
      Specified by:
      awaitUninterruptibly in interface ChannelFuture
      Specified by:
      awaitUninterruptibly in interface ChannelPromise
      Specified by:
      awaitUninterruptibly in interface Future<java.lang.Void>
      Specified by:
      awaitUninterruptibly in interface Promise<java.lang.Void>
    • awaitUninterruptibly

      public boolean awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)
      Description copied from interface: Future
      Waits for this future to be completed within the specified time limit without interruption. This method catches an InterruptedException and discards it silently.
      Specified by:
      awaitUninterruptibly in interface Future<java.lang.Void>
      Returns:
      true if and only if the future was completed within the specified time limit
    • awaitUninterruptibly

      public boolean awaitUninterruptibly(long timeoutMillis)
      Description copied from interface: Future
      Waits for this future to be completed within the specified time limit without interruption. This method catches an InterruptedException and discards it silently.
      Specified by:
      awaitUninterruptibly in interface Future<java.lang.Void>
      Returns:
      true if and only if the future was completed within the specified time limit
    • channel

      public Channel channel()
      Description copied from interface: ChannelFuture
      Returns a channel where the I/O operation associated with this future takes place.
      Specified by:
      channel in interface ChannelFuture
      Specified by:
      channel in interface ChannelPromise
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface java.util.concurrent.Future<java.lang.Void>
    • isSuccess

      public boolean isSuccess()
      Description copied from interface: Future
      Returns true if and only if the I/O operation was completed successfully.
      Specified by:
      isSuccess in interface Future<java.lang.Void>
    • setUncancellable

      public boolean setUncancellable()
      Description copied from interface: Promise
      Make this future impossible to cancel.
      Specified by:
      setUncancellable in interface Promise<java.lang.Void>
      Returns:
      true if and only if successfully marked this future as uncancellable or it is already done without being cancelled. false if this future has been cancelled already.
    • isCancellable

      public boolean isCancellable()
      Description copied from interface: Future
      returns true if and only if the operation can be cancelled via Future.cancel(boolean).
      Specified by:
      isCancellable in interface Future<java.lang.Void>
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface java.util.concurrent.Future<java.lang.Void>
    • cause

      public java.lang.Throwable cause()
      Description copied from interface: Future
      Returns the cause of the failed I/O operation if the I/O operation has failed.
      Specified by:
      cause in interface Future<java.lang.Void>
      Returns:
      the cause of the failure. null if succeeded or this future is not completed yet.
    • sync

      public VoidChannelPromise sync()
      Description copied from interface: Future
      Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
      Specified by:
      sync in interface ChannelFuture
      Specified by:
      sync in interface ChannelPromise
      Specified by:
      sync in interface Future<java.lang.Void>
      Specified by:
      sync in interface Promise<java.lang.Void>
    • syncUninterruptibly

      public VoidChannelPromise syncUninterruptibly()
      Description copied from interface: Future
      Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
      Specified by:
      syncUninterruptibly in interface ChannelFuture
      Specified by:
      syncUninterruptibly in interface ChannelPromise
      Specified by:
      syncUninterruptibly in interface Future<java.lang.Void>
      Specified by:
      syncUninterruptibly in interface Promise<java.lang.Void>
    • setFailure

      public VoidChannelPromise setFailure(java.lang.Throwable cause)
      Description copied from interface: Promise
      Marks this future as a failure and notifies all listeners. If it is success or failed already it will throw an IllegalStateException.
      Specified by:
      setFailure in interface ChannelPromise
      Specified by:
      setFailure in interface Promise<java.lang.Void>
    • setSuccess

      public VoidChannelPromise setSuccess()
      Specified by:
      setSuccess in interface ChannelPromise
    • tryFailure

      public boolean tryFailure(java.lang.Throwable cause)
      Description copied from interface: Promise
      Marks this future as a failure and notifies all listeners.
      Specified by:
      tryFailure in interface Promise<java.lang.Void>
      Returns:
      true if and only if successfully marked this future as a failure. Otherwise false because this future is already marked as either a success or a failure.
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      If the cancellation was successful it will fail the future with a CancellationException.
      Specified by:
      cancel in interface Future<java.lang.Void>
      Specified by:
      cancel in interface java.util.concurrent.Future<java.lang.Void>
      Parameters:
      mayInterruptIfRunning - this value has no effect in this implementation.
    • trySuccess

      public boolean trySuccess()
      Specified by:
      trySuccess in interface ChannelPromise
    • fail

      private static void fail()
    • setSuccess

      public VoidChannelPromise setSuccess(java.lang.Void result)
      Description copied from interface: Promise
      Marks this future as a success and notifies all listeners. If it is success or failed already it will throw an IllegalStateException.
      Specified by:
      setSuccess in interface ChannelPromise
      Specified by:
      setSuccess in interface Promise<java.lang.Void>
    • trySuccess

      public boolean trySuccess(java.lang.Void result)
      Description copied from interface: Promise
      Marks this future as a success and notifies all listeners.
      Specified by:
      trySuccess in interface Promise<java.lang.Void>
      Returns:
      true if and only if successfully marked this future as a success. Otherwise false because this future is already marked as either a success or a failure.
    • getNow

      public java.lang.Void getNow()
      Description copied from interface: Future
      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.

      Specified by:
      getNow in interface Future<java.lang.Void>
    • unvoid

      public ChannelPromise unvoid()
      Description copied from interface: ChannelPromise
      Returns a new ChannelPromise if ChannelFuture.isVoid() returns true otherwise itself.
      Specified by:
      unvoid in interface ChannelPromise
    • isVoid

      public boolean isVoid()
      Description copied from interface: ChannelFuture
      Specified by:
      isVoid in interface ChannelFuture
    • fireException0

      private void fireException0(java.lang.Throwable cause)