org.jboss.netty.channel

## Class DefaultChannelFuture

- java.lang.Object
- - org.jboss.netty.channel.DefaultChannelFuture

All Implemented Interfaces:
  ChannelFuture

Direct Known Subclasses:
  ChannelRunnableWrapper

    public class DefaultChannelFuture
    extends Object
    implements ChannelFuture

The default `ChannelFuture` implementation. It is recommended to use `Channels.future(Channel)` and `Channels.future(Channel, boolean)` to create a new `ChannelFuture` rather than calling the constructor explicitly.

### Constructor Summary

Constructors
Constructor and Description
`DefaultChannelFuture(Channel channel, boolean cancellable)` Creates a new instance.

### Method Summary

Methods
`void` `addListener(ChannelFutureListener listener)` Adds the specified listener to this future.
`ChannelFuture` `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, TimeUnit unit)` Waits for this future to be completed within the specified time limit.
`ChannelFuture` `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, TimeUnit unit)` Waits for this future to be completed within the specified time limit without interruption.
`boolean` `cancel()` Cancels the I/O operation associated with this future and notifies all listeners if canceled successfully.
`Throwable` `getCause()` Returns the cause of the failed I/O operation if the I/O operation has failed.
`Channel` `getChannel()` Returns a channel where the I/O operation associated with this future takes place.
`boolean` `isCancelled()` Returns `true` if and only if this future was cancelled by a `ChannelFuture.cancel()` method.
`boolean` `isDone()` Returns `true` if and only if this future is complete, regardless of whether the operation was successful, failed, or cancelled.
`boolean` `isSuccess()` Returns `true` if and only if the I/O operation was completed successfully.
`static boolean` `isUseDeadLockChecker()` Returns `true` if and only if the dead lock checker is enabled.
`void` `removeListener(ChannelFutureListener listener)` Removes the specified listener from this future.
`ChannelFuture` `rethrowIfFailed()`
`boolean` `setFailure(Throwable cause)` Marks this future as a failure and notifies all listeners.
`boolean` `setProgress(long amount, long current, long total)` Notifies the progress of the operation to the listeners that implements `ChannelFutureProgressListener`.
`boolean` `setSuccess()` Marks this future as a success and notifies all listeners.
`static void` `setUseDeadLockChecker(boolean useDeadLockChecker)` Enables or disables the dead lock checker.
`ChannelFuture` `sync()` Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
`ChannelFuture` `syncUninterruptibly()` Waits for this future until it is done, and rethrows the cause of the failure if this future failed.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultChannelFuture

    public DefaultChannelFuture(Channel channel,
                        boolean cancellable)

Creates a new instance.

Parameters:
  `channel` - the `Channel` associated with this future
  `cancellable` - `true` if and only if this future can be canceled

### Method Detail

#### isUseDeadLockChecker

    public static boolean isUseDeadLockChecker()

Returns `true` if and only if the dead lock checker is enabled.

#### setUseDeadLockChecker

    public static void setUseDeadLockChecker(boolean useDeadLockChecker)

Enables or disables the dead lock checker. It is not recommended to disable the dead lock checker. Disable it at your own risk!

#### getChannel

    public Channel getChannel()

Description copied from interface: `ChannelFuture`
Returns a channel where the I/O operation associated with this future takes place.

Specified by:
  `getChannel` in interface `ChannelFuture`

#### isDone

    public boolean isDone()

Description copied from interface: `ChannelFuture`
Returns `true` if and only if this future is complete, regardless of whether the operation was successful, failed, or cancelled.

Specified by:
  `isDone` in interface `ChannelFuture`

#### isSuccess

    public boolean isSuccess()

Description copied from interface: `ChannelFuture`
Returns `true` if and only if the I/O operation was completed successfully.

Specified by:
  `isSuccess` in interface `ChannelFuture`

#### getCause

    public Throwable getCause()

Description copied from interface: `ChannelFuture`
Returns the cause of the failed I/O operation if the I/O operation has failed.

Specified by:
  `getCause` in interface `ChannelFuture`
Returns:
  the cause of the failure. `null` if succeeded or this future is not completed yet.

#### isCancelled

    public boolean isCancelled()

Description copied from interface: `ChannelFuture`
Returns `true` if and only if this future was cancelled by a `ChannelFuture.cancel()` method.

Specified by:
  `isCancelled` in interface `ChannelFuture`

#### addListener

    public void addListener(ChannelFutureListener listener)

Description copied from interface: `ChannelFuture`
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`

#### removeListener

    public void removeListener(ChannelFutureListener listener)

Description copied from interface: `ChannelFuture`
Removes 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`

#### rethrowIfFailed

    public ChannelFuture rethrowIfFailed()
                                  throws Exception

Specified by:
  `rethrowIfFailed` in interface `ChannelFuture`
Throws:
  `Exception`

#### sync

    public ChannelFuture sync()
                       throws InterruptedException

Description copied from interface: `ChannelFuture`
Waits for this future until it is done, and rethrows the cause of the failure if this future failed. If the cause of the failure is a checked exception, it is wrapped with a new `ChannelException` before being thrown.

Specified by:
  `sync` in interface `ChannelFuture`
Throws:
  `InterruptedException`

#### syncUninterruptibly

    public ChannelFuture syncUninterruptibly()

Description copied from interface: `ChannelFuture`
Waits for this future until it is done, and rethrows the cause of the failure if this future failed. If the cause of the failure is a checked exception, it is wrapped with a new `ChannelException` before being thrown.

Specified by:
  `syncUninterruptibly` in interface `ChannelFuture`

#### await

    public ChannelFuture await()
                        throws InterruptedException

Description copied from interface: `ChannelFuture`
Waits for this future to be completed.

Specified by:
  `await` in interface `ChannelFuture`
Throws:
  `InterruptedException` - if the current thread was interrupted

#### await

    public boolean await(long timeout,
                TimeUnit unit)
                  throws InterruptedException

Description copied from interface: `ChannelFuture`
Waits for this future to be completed within the specified time limit.

Specified by:
  `await` in interface `ChannelFuture`
Returns:
  `true` if and only if the future was completed within the specified time limit
Throws:
  `InterruptedException` - if the current thread was interrupted

#### await

    public boolean await(long timeoutMillis)
                  throws InterruptedException

Description copied from interface: `ChannelFuture`
Waits for this future to be completed within the specified time limit.

Specified by:
  `await` in interface `ChannelFuture`
Returns:
  `true` if and only if the future was completed within the specified time limit
Throws:
  `InterruptedException` - if the current thread was interrupted

#### awaitUninterruptibly

    public ChannelFuture awaitUninterruptibly()

Description copied from interface: `ChannelFuture`
Waits for this future to be completed without interruption. This method catches an `InterruptedException` and discards it silently.

Specified by:
  `awaitUninterruptibly` in interface `ChannelFuture`

#### awaitUninterruptibly

    public boolean awaitUninterruptibly(long timeout,
                               TimeUnit unit)

Description copied from interface: `ChannelFuture`
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 `ChannelFuture`
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: `ChannelFuture`
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 `ChannelFuture`
Returns:
  `true` if and only if the future was completed within the specified time limit

#### setSuccess

    public boolean setSuccess()

Description copied from interface: `ChannelFuture`
Marks this future as a success and notifies all listeners.

Specified by:
  `setSuccess` in interface `ChannelFuture`
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.

#### setFailure

    public boolean setFailure(Throwable cause)

Description copied from interface: `ChannelFuture`
Marks this future as a failure and notifies all listeners.

Specified by:
  `setFailure` in interface `ChannelFuture`
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()

Description copied from interface: `ChannelFuture`
Cancels the I/O operation associated with this future and notifies all listeners if canceled successfully.

Specified by:
  `cancel` in interface `ChannelFuture`
Returns:
  `true` if and only if the operation has been canceled. `false` if the operation can't be canceled or is already completed.

#### setProgress

    public boolean setProgress(long amount,
                      long current,
                      long total)

Description copied from interface: `ChannelFuture`
Notifies the progress of the operation to the listeners that implements `ChannelFutureProgressListener`. Please note that this method will not do anything and return `false` if this future is complete already.

Specified by:
  `setProgress` in interface `ChannelFuture`
Returns:
  `true` if and only if notification was made.