Package io.netty.channel
Class DefaultChannelPromise
- java.lang.Object
-
- io.netty.util.concurrent.AbstractFuture<V>
-
- io.netty.util.concurrent.DefaultPromise<java.lang.Void>
-
- io.netty.channel.DefaultChannelPromise
-
- All Implemented Interfaces:
ChannelFuture,ChannelPromise,Future<java.lang.Void>,Promise<java.lang.Void>,java.util.concurrent.Future<java.lang.Void>
public class DefaultChannelPromise extends DefaultPromise<java.lang.Void> implements ChannelPromise
The defaultChannelPromiseimplementation. It is recommended to useChannel.newPromise()to create a newChannelPromiserather than calling the constructor explicitly.
-
-
Field Summary
-
Fields inherited from class io.netty.util.concurrent.DefaultPromise
PROPERTY_MAX_LISTENER_STACK_DEPTH
-
-
Constructor Summary
Constructors Constructor Description DefaultChannelPromise(Channel channel)Creates a new instance.DefaultChannelPromise(Channel channel, EventExecutor executor)Creates a new instance.
-
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.ChannelPromiseawaitUninterruptibly()Waits for this future to be completed without interruption.Channelchannel()Returns a channel where the I/O operation associated with this future takes place.protected voidcheckDeadLock()protected EventExecutorexecutor()Get the executor used to notify listeners when this promise is complete.longflushCheckpoint()voidflushCheckpoint(long checkpoint)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()ChannelPromisepromise()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.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.booleantrySuccess()ChannelPromiseunvoid()-
Methods inherited from class io.netty.util.concurrent.DefaultPromise
await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, cause, get, get, getNow, isCancellable, isCancelled, isDone, isSuccess, notifyListener, setUncancellable, toString, toStringBuilder, tryFailure, trySuccess
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.util.concurrent.Future
await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, cause, getNow, isCancellable, isSuccess
-
Methods inherited from interface io.netty.util.concurrent.Promise
setUncancellable, tryFailure, trySuccess
-
-
-
-
Constructor Detail
-
DefaultChannelPromise
public DefaultChannelPromise(Channel channel)
Creates a new instance.- Parameters:
channel- theChannelassociated with this future
-
DefaultChannelPromise
public DefaultChannelPromise(Channel channel, EventExecutor executor)
Creates a new instance.- Parameters:
channel- theChannelassociated with this future
-
-
Method Detail
-
executor
protected EventExecutor executor()
Description copied from class:DefaultPromiseGet the executor used to notify listeners when this promise is complete.It is assumed this executor will protect against
StackOverflowErrorexceptions. The executor may be used to avoidStackOverflowErrorby executing aRunnableif the stack depth exceeds a threshold.- Overrides:
executorin classDefaultPromise<java.lang.Void>- Returns:
- The executor used to notify listeners when this promise is complete.
-
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()
- Specified by:
setSuccessin 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>- Overrides:
setSuccessin classDefaultPromise<java.lang.Void>
-
trySuccess
public boolean trySuccess()
- Specified by:
trySuccessin interfaceChannelPromise
-
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>- Overrides:
setFailurein classDefaultPromise<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>- Overrides:
addListenerin classDefaultPromise<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>- Overrides:
addListenersin classDefaultPromise<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>- Overrides:
removeListenerin classDefaultPromise<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>- Overrides:
removeListenersin classDefaultPromise<java.lang.Void>
-
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>- Overrides:
syncin classDefaultPromise<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>- Overrides:
syncUninterruptiblyin classDefaultPromise<java.lang.Void>
-
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>- Overrides:
awaitin classDefaultPromise<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>- Overrides:
awaitUninterruptiblyin classDefaultPromise<java.lang.Void>
-
flushCheckpoint
public long flushCheckpoint()
-
flushCheckpoint
public void flushCheckpoint(long checkpoint)
-
promise
public ChannelPromise promise()
-
checkDeadLock
protected void checkDeadLock()
- Overrides:
checkDeadLockin classDefaultPromise<java.lang.Void>
-
unvoid
public ChannelPromise unvoid()
Description copied from interface:ChannelPromise- Specified by:
unvoidin interfaceChannelPromise
-
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
-
-