Class DefaultChannelFuture
java.lang.Object
org.jboss.netty.channel.DefaultChannelFuture
- All Implemented Interfaces:
ChannelFuture
- Direct Known Subclasses:
AbstractChannel.ChannelCloseFuture, ChannelRunnableWrapper, SslHandler.SSLEngineInboundCloseFuture
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate static final Throwableprivate Throwableprivate final Channelprivate static booleanprivate booleanprivate ChannelFutureListenerprivate static final InternalLoggerprivate List<ChannelFutureListener> private List<ChannelFutureProgressListener> private static booleanprivate int -
Constructor Summary
ConstructorsConstructorDescriptionDefaultChannelFuture(Channel channel, boolean cancellable) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ChannelFutureListener listener) Adds the specified listener to this future.await()Waits for this future to be completed.booleanawait(long timeoutMillis) Waits for this future to be completed within the specified time limit.booleanWaits for this future to be completed within the specified time limit.private booleanawait0(long timeoutNanos, boolean interruptable) Waits for this future to be completed without interruption.booleanawaitUninterruptibly(long timeoutMillis) Waits for this future to be completed within the specified time limit without interruption.booleanawaitUninterruptibly(long timeout, TimeUnit unit) Waits for this future to be completed within the specified time limit without interruption.booleancancel()Cancels the I/O operation associated with this future and notifies all listeners if canceled successfully.private static voidgetCause()Returns the cause of the failed I/O operation if the I/O operation has failed.Returns a channel where the I/O operation associated with this future takes place.booleanReturnstrueif and only if this future was cancelled by aChannelFuture.cancel()method.booleanisDone()Returnstrueif and only if this future is complete, regardless of whether the operation was successful, failed, or cancelled.booleanReturnstrueif and only if the I/O operation was completed successfully.static booleanReturnstrueif and only if the dead lock checker is enabled.private voidprivate voidprivate voidnotifyProgressListener(ChannelFutureProgressListener l, long amount, long current, long total) voidremoveListener(ChannelFutureListener listener) Removes the specified listener from this future.private voidbooleansetFailure(Throwable cause) Marks this future as a failure and notifies all listeners.booleansetProgress(long amount, long current, long total) Notifies the progress of the operation to the listeners that implementsChannelFutureProgressListener.booleanMarks this future as a success and notifies all listeners.static voidsetUseDeadLockChecker(boolean useDeadLockChecker) Enables or disables the dead lock checker.sync()Waits for this future until it is done, and rethrows the cause of the failure if this future failed.Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
-
Field Details
-
logger
-
CANCELLED
-
useDeadLockChecker
private static volatile boolean useDeadLockChecker -
disabledDeadLockCheckerOnce
private static boolean disabledDeadLockCheckerOnce -
channel
-
cancellable
private final boolean cancellable -
firstListener
-
otherListeners
-
progressListeners
-
done
private boolean done -
cause
-
waiters
private int waiters
-
-
Constructor Details
-
DefaultChannelFuture
-
-
Method Details
-
isUseDeadLockChecker
public static boolean isUseDeadLockChecker()Returnstrueif 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
Description copied from interface:ChannelFutureReturns a channel where the I/O operation associated with this future takes place.- Specified by:
getChannelin interfaceChannelFuture
-
isDone
public boolean isDone()Description copied from interface:ChannelFutureReturnstrueif and only if this future is complete, regardless of whether the operation was successful, failed, or cancelled.- Specified by:
isDonein interfaceChannelFuture
-
isSuccess
public boolean isSuccess()Description copied from interface:ChannelFutureReturnstrueif and only if the I/O operation was completed successfully.- Specified by:
isSuccessin interfaceChannelFuture
-
getCause
Description copied from interface:ChannelFutureReturns the cause of the failed I/O operation if the I/O operation has failed.- Specified by:
getCausein interfaceChannelFuture- Returns:
- the cause of the failure.
nullif succeeded or this future is not completed yet.
-
isCancelled
public boolean isCancelled()Description copied from interface:ChannelFutureReturnstrueif and only if this future was cancelled by aChannelFuture.cancel()method.- Specified by:
isCancelledin interfaceChannelFuture
-
addListener
Description copied from interface:ChannelFutureAdds 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:
addListenerin interfaceChannelFuture
-
removeListener
Description copied from interface:ChannelFutureRemoves 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:
removeListenerin interfaceChannelFuture
-
sync
Description copied from interface:ChannelFutureWaits 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 newChannelExceptionbefore being thrown.- Specified by:
syncin interfaceChannelFuture- Throws:
InterruptedException
-
syncUninterruptibly
Description copied from interface:ChannelFutureWaits 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 newChannelExceptionbefore being thrown.- Specified by:
syncUninterruptiblyin interfaceChannelFuture
-
rethrowIfFailed0
private void rethrowIfFailed0() -
await
Description copied from interface:ChannelFutureWaits for this future to be completed.- Specified by:
awaitin interfaceChannelFuture- Throws:
InterruptedException- if the current thread was interrupted
-
await
Description copied from interface:ChannelFutureWaits for this future to be completed within the specified time limit.- Specified by:
awaitin interfaceChannelFuture- Returns:
trueif and only if the future was completed within the specified time limit- Throws:
InterruptedException- if the current thread was interrupted
-
await
Description copied from interface:ChannelFutureWaits for this future to be completed within the specified time limit.- Specified by:
awaitin interfaceChannelFuture- Returns:
trueif and only if the future was completed within the specified time limit- Throws:
InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
Description copied from interface:ChannelFutureWaits for this future to be completed without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceChannelFuture
-
awaitUninterruptibly
Description copied from interface:ChannelFutureWaits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceChannelFuture- Returns:
trueif and only if the future was completed within the specified time limit
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis) Description copied from interface:ChannelFutureWaits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceChannelFuture- Returns:
trueif and only if the future was completed within the specified time limit
-
await0
- Throws:
InterruptedException
-
checkDeadLock
private static void checkDeadLock() -
setSuccess
public boolean setSuccess()Description copied from interface:ChannelFutureMarks this future as a success and notifies all listeners.- Specified by:
setSuccessin interfaceChannelFuture- Returns:
trueif and only if successfully marked this future as a success. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
setFailure
Description copied from interface:ChannelFutureMarks this future as a failure and notifies all listeners.- Specified by:
setFailurein interfaceChannelFuture- Returns:
trueif and only if successfully marked this future as a failure. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
cancel
public boolean cancel()Description copied from interface:ChannelFutureCancels the I/O operation associated with this future and notifies all listeners if canceled successfully.- Specified by:
cancelin interfaceChannelFuture- Returns:
trueif and only if the operation has been canceled.falseif the operation can't be canceled or is already completed.
-
notifyListeners
private void notifyListeners() -
notifyListener
-
setProgress
public boolean setProgress(long amount, long current, long total) Description copied from interface:ChannelFutureNotifies the progress of the operation to the listeners that implementsChannelFutureProgressListener. Please note that this method will not do anything and returnfalseif this future is complete already.- Specified by:
setProgressin interfaceChannelFuture- Returns:
trueif and only if notification was made.
-
notifyProgressListener
private void notifyProgressListener(ChannelFutureProgressListener l, long amount, long current, long total)
-