Class DelegatingChannelPromiseNotifier
java.lang.Object
io.netty.channel.DelegatingChannelPromiseNotifier
- All Implemented Interfaces:
ChannelFuture, ChannelFutureListener, ChannelPromise, Future<Void>, GenericFutureListener<ChannelFuture>, Promise<Void>, Future<Void>, EventListener
@UnstableApi
public final class DelegatingChannelPromiseNotifier
extends Object
implements ChannelPromise, ChannelFutureListener
-
Field Summary
Fields inherited from interface ChannelFutureListener
CLOSE, CLOSE_ON_FAILURE, FIRE_EXCEPTION_ON_FAILURE -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingChannelPromiseNotifier(ChannelPromise delegate, boolean logNotifyFailure) -
Method Summary
Modifier and TypeMethodDescriptionaddListener(GenericFutureListener<? extends Future<? super Void>> listener) Adds the specified listener to this future.addListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) Adds the specified listeners 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.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(boolean mayInterruptIfRunning) If the cancellation was successful it will fail the future with aCancellationException.cause()Returns the cause of the failed I/O operation if the I/O operation has failed.channel()Returns a channel where the I/O operation associated with this future takes place.get()getNow()Return the result without blocking.booleanreturnstrueif and only if the operation can be cancelled viaFuture.cancel(boolean).booleanbooleanisDone()booleanReturnstrueif 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.removeListener(GenericFutureListener<? extends Future<? super Void>> listener) Removes the first occurrence of the specified listener from this future.removeListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) Removes the first occurrence for each of the listeners from this future.setFailure(Throwable cause) Marks this future as a failure and notifies all listeners.setSuccess(Void result) Marks this future as a success and notifies all listeners.booleanMake this future impossible to cancel.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.booleantryFailure(Throwable cause) Marks this future as a failure and notifies all listeners.booleanbooleantrySuccess(Void result) Marks this future as a success and notifies all listeners.unvoid()
-
Constructor Details
-
DelegatingChannelPromiseNotifier
-
DelegatingChannelPromiseNotifier
-
-
Method Details
-
operationComplete
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:
Exception
-
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
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<Void>
-
setSuccess
- Specified by:
setSuccessin interfaceChannelPromise
-
trySuccess
public boolean trySuccess()- Specified by:
trySuccessin interfaceChannelPromise
-
trySuccess
Description copied from interface:PromiseMarks this future as a success and notifies all listeners.- Specified by:
trySuccessin interfacePromise<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
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<Void>
-
addListener
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<Void>- Specified by:
addListenerin interfacePromise<Void>
-
addListeners
public ChannelPromise addListeners(GenericFutureListener<? extends Future<? super 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<Void>- Specified by:
addListenersin interfacePromise<Void>
-
removeListener
public ChannelPromise removeListener(GenericFutureListener<? extends Future<? super 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<Void>- Specified by:
removeListenerin interfacePromise<Void>
-
removeListeners
public ChannelPromise removeListeners(GenericFutureListener<? extends Future<? super 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<Void>- Specified by:
removeListenersin interfacePromise<Void>
-
tryFailure
Description copied from interface:PromiseMarks this future as a failure and notifies all listeners.- Specified by:
tryFailurein interfacePromise<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<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
Description copied from interface:FutureWaits for this future to be completed.- Specified by:
awaitin interfaceChannelFuture- Specified by:
awaitin interfaceChannelPromise- Specified by:
awaitin interfaceFuture<Void>- Specified by:
awaitin interfacePromise<Void>- Throws:
InterruptedException- if the current thread was interrupted
-
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<Void>- Specified by:
awaitUninterruptiblyin interfacePromise<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
Description copied from interface:ChannelPromise- Specified by:
unvoidin interfaceChannelPromise
-
await
Description copied from interface:FutureWaits for this future to be completed within the specified time limit.- Specified by:
awaitin interfaceFuture<Void>- 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:FutureWaits for this future to be completed within the specified time limit.- Specified by:
awaitin interfaceFuture<Void>- 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: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<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<Void>- Returns:
trueif and only if the future was completed within the specified time limit
-
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
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<Void>
-
isDone
-
get
- Specified by:
getin interfaceFuture<Void>- Throws:
InterruptedExceptionExecutionException
-
get
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
getin interfaceFuture<Void>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
sync
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<Void>- Specified by:
syncin interfacePromise<Void>- Throws:
InterruptedException
-
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<Void>- Specified by:
syncUninterruptiblyin interfacePromise<Void>
-
isSuccess
-
isCancellable
public boolean isCancellable()Description copied from interface:Futurereturnstrueif and only if the operation can be cancelled viaFuture.cancel(boolean).- Specified by:
isCancellablein interfaceFuture<Void>
-
cause
-