Package io.netty.channel
Class DelegatingChannelPromiseNotifier
- java.lang.Object
-
- io.netty.channel.DelegatingChannelPromiseNotifier
-
- All Implemented Interfaces:
ChannelFuture,ChannelFutureListener,ChannelPromise,Future<java.lang.Void>,GenericFutureListener<ChannelFuture>,Promise<java.lang.Void>,java.util.concurrent.Future<java.lang.Void>,java.util.EventListener
@UnstableApi public final class DelegatingChannelPromiseNotifier extends java.lang.Object implements ChannelPromise, ChannelFutureListener
-
-
Field Summary
-
Fields inherited from interface io.netty.channel.ChannelFutureListener
CLOSE, CLOSE_ON_FAILURE, FIRE_EXCEPTION_ON_FAILURE
-
-
Constructor Summary
Constructors Constructor Description DelegatingChannelPromiseNotifier(ChannelPromise delegate)DelegatingChannelPromiseNotifier(ChannelPromise delegate, boolean logNotifyFailure)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelPromiseaddListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)Adds the specified listener to this future.ChannelPromiseaddListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)Adds the specified listeners to this future.ChannelPromiseawait()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.ChannelPromiseawaitUninterruptibly()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(boolean mayInterruptIfRunning)If the cancellation was successful it will fail the future with aCancellationException.java.lang.Throwablecause()Returns the cause of the failed I/O operation if the I/O operation has failed.Channelchannel()Returns a channel where the I/O operation associated with this future takes place.java.lang.Voidget()java.lang.Voidget(long timeout, java.util.concurrent.TimeUnit unit)java.lang.VoidgetNow()Return the result without blocking.booleanisCancellable()returnstrueif and only if the operation can be cancelled viaFuture.cancel(boolean).booleanisCancelled()booleanisDone()booleanisSuccess()Returnstrueif and only if the I/O operation was completed successfully.booleanisVoid()Returnstrueif thisChannelFutureis a void future and so not allow to call any of the following methods:ChannelFuture.addListener(GenericFutureListener)ChannelFuture.addListeners(GenericFutureListener[])ChannelFuture.await()Future.await(long, TimeUnit)()}Future.await(long)()}ChannelFuture.awaitUninterruptibly()ChannelFuture.sync()ChannelFuture.syncUninterruptibly()voidoperationComplete(ChannelFuture future)Invoked when the operation associated with theFuturehas been completed.ChannelPromiseremoveListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)Removes the first occurrence of the specified listener from this future.ChannelPromiseremoveListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)Removes the first occurrence for each of the listeners from this future.ChannelPromisesetFailure(java.lang.Throwable cause)Marks this future as a failure and notifies all listeners.ChannelPromisesetSuccess()ChannelPromisesetSuccess(java.lang.Void result)Marks this future as a success and notifies all listeners.booleansetUncancellable()Make this future impossible to cancel.ChannelPromisesync()Waits for this future until it is done, and rethrows the cause of the failure if this future failed.ChannelPromisesyncUninterruptibly()Waits for this future until it is done, and rethrows the cause of the failure if this future failed.booleantryFailure(java.lang.Throwable cause)Marks this future as a failure and notifies all listeners.booleantrySuccess()booleantrySuccess(java.lang.Void result)Marks this future as a success and notifies all listeners.ChannelPromiseunvoid()
-
-
-
Constructor Detail
-
DelegatingChannelPromiseNotifier
public DelegatingChannelPromiseNotifier(ChannelPromise delegate)
-
DelegatingChannelPromiseNotifier
public DelegatingChannelPromiseNotifier(ChannelPromise delegate, boolean logNotifyFailure)
-
-
Method Detail
-
operationComplete
public void operationComplete(ChannelFuture future) throws java.lang.Exception
Description copied from interface:GenericFutureListenerInvoked when the operation associated with theFuturehas been completed.- Specified by:
operationCompletein interfaceGenericFutureListener<ChannelFuture>- Parameters:
future- the sourceFuturewhich called this callback- Throws:
java.lang.Exception
-
channel
public Channel channel()
Description copied from interface:ChannelFutureReturns a channel where the I/O operation associated with this future takes place.- Specified by:
channelin interfaceChannelFuture- Specified by:
channelin interfaceChannelPromise
-
setSuccess
public ChannelPromise setSuccess(java.lang.Void result)
Description copied from interface:PromiseMarks this future as a success and notifies all listeners. If it is success or failed already it will throw anIllegalStateException.- Specified by:
setSuccessin interfaceChannelPromise- Specified by:
setSuccessin interfacePromise<java.lang.Void>
-
setSuccess
public ChannelPromise setSuccess()
- Specified by:
setSuccessin interfaceChannelPromise
-
trySuccess
public boolean trySuccess()
- Specified by:
trySuccessin interfaceChannelPromise
-
trySuccess
public boolean trySuccess(java.lang.Void result)
Description copied from interface:PromiseMarks this future as a success and notifies all listeners.- Specified by:
trySuccessin interfacePromise<java.lang.Void>- 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
public ChannelPromise setFailure(java.lang.Throwable cause)
Description copied from interface:PromiseMarks this future as a failure and notifies all listeners. If it is success or failed already it will throw anIllegalStateException.- Specified by:
setFailurein interfaceChannelPromise- Specified by:
setFailurein interfacePromise<java.lang.Void>
-
addListener
public ChannelPromise addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Description copied from interface:FutureAdds 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- Specified by:
addListenerin interfaceChannelPromise- Specified by:
addListenerin interfaceFuture<java.lang.Void>- Specified by:
addListenerin interfacePromise<java.lang.Void>
-
addListeners
public ChannelPromise addListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Description copied from interface:FutureAdds 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:
addListenersin interfaceChannelFuture- Specified by:
addListenersin interfaceChannelPromise- Specified by:
addListenersin interfaceFuture<java.lang.Void>- Specified by:
addListenersin interfacePromise<java.lang.Void>
-
removeListener
public ChannelPromise removeListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Description copied from interface:FutureRemoves 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:
removeListenerin interfaceChannelFuture- Specified by:
removeListenerin interfaceChannelPromise- Specified by:
removeListenerin interfaceFuture<java.lang.Void>- Specified by:
removeListenerin interfacePromise<java.lang.Void>
-
removeListeners
public ChannelPromise removeListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Description copied from interface:FutureRemoves 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:
removeListenersin interfaceChannelFuture- Specified by:
removeListenersin interfaceChannelPromise- Specified by:
removeListenersin interfaceFuture<java.lang.Void>- Specified by:
removeListenersin interfacePromise<java.lang.Void>
-
tryFailure
public boolean tryFailure(java.lang.Throwable cause)
Description copied from interface:PromiseMarks this future as a failure and notifies all listeners.- Specified by:
tryFailurein interfacePromise<java.lang.Void>- 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.
-
setUncancellable
public boolean setUncancellable()
Description copied from interface:PromiseMake this future impossible to cancel.- Specified by:
setUncancellablein interfacePromise<java.lang.Void>- Returns:
trueif and only if successfully marked this future as uncancellable or it is already done without being cancelled.falseif this future has been cancelled already.
-
await
public ChannelPromise await() throws java.lang.InterruptedException
Description copied from interface:FutureWaits for this future to be completed.- Specified by:
awaitin interfaceChannelFuture- Specified by:
awaitin interfaceChannelPromise- Specified by:
awaitin interfaceFuture<java.lang.Void>- Specified by:
awaitin interfacePromise<java.lang.Void>- Throws:
java.lang.InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
public ChannelPromise awaitUninterruptibly()
Description copied from interface:FutureWaits for this future to be completed without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceChannelFuture- Specified by:
awaitUninterruptiblyin interfaceChannelPromise- Specified by:
awaitUninterruptiblyin interfaceFuture<java.lang.Void>- Specified by:
awaitUninterruptiblyin interfacePromise<java.lang.Void>
-
isVoid
public boolean isVoid()
Description copied from interface:ChannelFutureReturnstrueif thisChannelFutureis a void future and so not allow to call any of the following methods:- Specified by:
isVoidin interfaceChannelFuture
-
unvoid
public ChannelPromise unvoid()
Description copied from interface:ChannelPromise- Specified by:
unvoidin interfaceChannelPromise
-
await
public boolean await(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionDescription copied from interface:FutureWaits for this future to be completed within the specified time limit.
-
await
public boolean await(long timeoutMillis) throws java.lang.InterruptedExceptionDescription copied from interface:FutureWaits for this future to be completed within the specified time limit.
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)Description copied from interface:FutureWaits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceFuture<java.lang.Void>- Returns:
trueif and only if the future was completed within the specified time limit
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis)
Description copied from interface:FutureWaits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceFuture<java.lang.Void>- Returns:
trueif and only if the future was completed within the specified time limit
-
getNow
public java.lang.Void getNow()
Description copied from interface:FutureReturn the result without blocking. If the future is not done yet this will returnnull.As it is possible that a
nullvalue is used to mark the future as successful you also need to check if the future is really done withFuture.isDone()and not rely on the returnednullvalue.
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
Description copied from interface:FutureIf the cancellation was successful it will fail the future with aCancellationException.
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<java.lang.Void>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<java.lang.Void>
-
get
public java.lang.Void get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException- Specified by:
getin interfacejava.util.concurrent.Future<java.lang.Void>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
get
public java.lang.Void get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException- Specified by:
getin interfacejava.util.concurrent.Future<java.lang.Void>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
sync
public ChannelPromise sync() throws java.lang.InterruptedException
Description copied from interface:FutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
syncin interfaceChannelFuture- Specified by:
syncin interfaceChannelPromise- Specified by:
syncin interfaceFuture<java.lang.Void>- Specified by:
syncin interfacePromise<java.lang.Void>- Throws:
java.lang.InterruptedException
-
syncUninterruptibly
public ChannelPromise syncUninterruptibly()
Description copied from interface:FutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
syncUninterruptiblyin interfaceChannelFuture- Specified by:
syncUninterruptiblyin interfaceChannelPromise- Specified by:
syncUninterruptiblyin interfaceFuture<java.lang.Void>- Specified by:
syncUninterruptiblyin interfacePromise<java.lang.Void>
-
isSuccess
public boolean isSuccess()
Description copied from interface:FutureReturnstrueif and only if the I/O operation was completed successfully.
-
isCancellable
public boolean isCancellable()
Description copied from interface:Futurereturnstrueif and only if the operation can be cancelled viaFuture.cancel(boolean).- Specified by:
isCancellablein interfaceFuture<java.lang.Void>
-
cause
public java.lang.Throwable cause()
Description copied from interface:FutureReturns the cause of the failed I/O operation if the I/O operation has failed.
-
-