Package org.jboss.netty.channel
Class CompleteChannelFuture
- java.lang.Object
-
- org.jboss.netty.channel.CompleteChannelFuture
-
- All Implemented Interfaces:
ChannelFuture
- Direct Known Subclasses:
FailedChannelFuture,SucceededChannelFuture
public abstract class CompleteChannelFuture extends java.lang.Object implements ChannelFuture
A skeletalChannelFutureimplementation which represents aChannelFuturewhich has been completed already.
-
-
Field Summary
Fields Modifier and Type Field Description private Channelchannelprivate static InternalLoggerlogger
-
Constructor Summary
Constructors Modifier Constructor Description protectedCompleteChannelFuture(Channel channel)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ChannelFutureListener listener)Adds the specified listener to this future.ChannelFutureawait()Waits for this future to be completed.booleanawait(long timeoutMillis)Waits for this future to be completed within the specified time limit.booleanawait(long timeout, java.util.concurrent.TimeUnit unit)Waits for this future to be completed within the specified time limit.ChannelFutureawaitUninterruptibly()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, java.util.concurrent.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.ChannelgetChannel()Returns a channel where the I/O operation associated with this future takes place.booleanisCancelled()Returnstrueif 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.voidremoveListener(ChannelFutureListener listener)Removes the specified listener from this future.booleansetFailure(java.lang.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.booleansetSuccess()Marks this future as a success and notifies all listeners.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.netty.channel.ChannelFuture
getCause, isSuccess, sync, syncUninterruptibly
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
channel
private final Channel channel
-
-
Method Detail
-
addListener
public void addListener(ChannelFutureListener listener)
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
public void removeListener(ChannelFutureListener listener)
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
-
await
public ChannelFuture await() throws java.lang.InterruptedException
Description copied from interface:ChannelFutureWaits for this future to be completed.- Specified by:
awaitin interfaceChannelFuture- Throws:
java.lang.InterruptedException- if the current thread was interrupted
-
await
public boolean await(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionDescription 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:
java.lang.InterruptedException- if the current thread was interrupted
-
await
public boolean await(long timeoutMillis) throws java.lang.InterruptedExceptionDescription 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:
java.lang.InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
public ChannelFuture 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
public boolean awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)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
-
getChannel
public Channel 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
-
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.
-
setFailure
public boolean setFailure(java.lang.Throwable cause)
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.
-
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.
-
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.
-
isCancelled
public boolean isCancelled()
Description copied from interface:ChannelFutureReturnstrueif and only if this future was cancelled by aChannelFuture.cancel()method.- Specified by:
isCancelledin interfaceChannelFuture
-
-