Package io.netty.channel
Class DefaultChannelPromise
- All Implemented Interfaces:
ChannelFlushPromiseNotifier.FlushCheckpoint
,ChannelFuture
,ChannelPromise
,Future<Void>
,Promise<Void>
,Future<Void>
- Direct Known Subclasses:
AbstractBootstrap.PendingRegistrationPromise
,AbstractChannel.CloseFuture
,Http2CodecUtil.SimpleChannelPromiseAggregator
public class DefaultChannelPromise
extends DefaultPromise<Void>
implements ChannelPromise, ChannelFlushPromiseNotifier.FlushCheckpoint
The default
ChannelPromise
implementation. It is recommended to use ChannelOutboundInvoker.newPromise()
to create
a new ChannelPromise
rather than calling the constructor explicitly.-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultChannelPromise
(Channel channel) Creates a new instance.DefaultChannelPromise
(Channel channel, EventExecutor executor) Creates a new instance. -
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.Waits for this future to be completed without interruption.channel()
Returns a channel where the I/O operation associated with this future takes place.protected void
protected EventExecutor
executor()
Get the executor used to notify listeners when this promise is complete.long
void
flushCheckpoint
(long checkpoint) boolean
isVoid()
Returnstrue
if thisChannelFuture
is 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()
promise()
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.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.boolean
unvoid()
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 java.util.concurrent.Future
exceptionNow, get, get, isCancelled, isDone, resultNow, state
Methods inherited from interface io.netty.util.concurrent.Promise
setUncancellable, tryFailure, trySuccess
-
Field Details
-
channel
-
checkpoint
private long checkpoint
-
-
Constructor Details
-
Method Details
-
executor
Description copied from class:DefaultPromise
Get the executor used to notify listeners when this promise is complete.It is assumed this executor will protect against
StackOverflowError
exceptions. The executor may be used to avoidStackOverflowError
by executing aRunnable
if the stack depth exceeds a threshold.- Overrides:
executor
in classDefaultPromise<Void>
- Returns:
- The executor used to notify listeners when this promise is complete.
-
channel
Description copied from interface:ChannelFuture
Returns a channel where the I/O operation associated with this future takes place.- Specified by:
channel
in interfaceChannelFuture
- Specified by:
channel
in interfaceChannelPromise
-
setSuccess
- Specified by:
setSuccess
in interfaceChannelPromise
-
setSuccess
Description copied from interface:Promise
Marks this future as a success and notifies all listeners. If it is success or failed already it will throw anIllegalStateException
.- Specified by:
setSuccess
in interfaceChannelPromise
- Specified by:
setSuccess
in interfacePromise<Void>
- Overrides:
setSuccess
in classDefaultPromise<Void>
-
trySuccess
public boolean trySuccess()- Specified by:
trySuccess
in interfaceChannelPromise
-
setFailure
Description copied from interface:Promise
Marks this future as a failure and notifies all listeners. If it is success or failed already it will throw anIllegalStateException
.- Specified by:
setFailure
in interfaceChannelPromise
- Specified by:
setFailure
in interfacePromise<Void>
- Overrides:
setFailure
in classDefaultPromise<Void>
-
addListener
Description copied from interface:Future
Adds 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:
addListener
in interfaceChannelFuture
- Specified by:
addListener
in interfaceChannelPromise
- Specified by:
addListener
in interfaceFuture<Void>
- Specified by:
addListener
in interfacePromise<Void>
- Overrides:
addListener
in classDefaultPromise<Void>
-
addListeners
public ChannelPromise addListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) Description copied from interface:Future
Adds 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:
addListeners
in interfaceChannelFuture
- Specified by:
addListeners
in interfaceChannelPromise
- Specified by:
addListeners
in interfaceFuture<Void>
- Specified by:
addListeners
in interfacePromise<Void>
- Overrides:
addListeners
in classDefaultPromise<Void>
-
removeListener
public ChannelPromise removeListener(GenericFutureListener<? extends Future<? super Void>> listener) Description copied from interface:Future
Removes 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:
removeListener
in interfaceChannelFuture
- Specified by:
removeListener
in interfaceChannelPromise
- Specified by:
removeListener
in interfaceFuture<Void>
- Specified by:
removeListener
in interfacePromise<Void>
- Overrides:
removeListener
in classDefaultPromise<Void>
-
removeListeners
public ChannelPromise removeListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) Description copied from interface:Future
Removes 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:
removeListeners
in interfaceChannelFuture
- Specified by:
removeListeners
in interfaceChannelPromise
- Specified by:
removeListeners
in interfaceFuture<Void>
- Specified by:
removeListeners
in interfacePromise<Void>
- Overrides:
removeListeners
in classDefaultPromise<Void>
-
sync
Description copied from interface:Future
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
sync
in interfaceChannelFuture
- Specified by:
sync
in interfaceChannelPromise
- Specified by:
sync
in interfaceFuture<Void>
- Specified by:
sync
in interfacePromise<Void>
- Overrides:
sync
in classDefaultPromise<Void>
- Throws:
InterruptedException
-
syncUninterruptibly
Description copied from interface:Future
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
syncUninterruptibly
in interfaceChannelFuture
- Specified by:
syncUninterruptibly
in interfaceChannelPromise
- Specified by:
syncUninterruptibly
in interfaceFuture<Void>
- Specified by:
syncUninterruptibly
in interfacePromise<Void>
- Overrides:
syncUninterruptibly
in classDefaultPromise<Void>
-
await
Description copied from interface:Future
Waits for this future to be completed.- Specified by:
await
in interfaceChannelFuture
- Specified by:
await
in interfaceChannelPromise
- Specified by:
await
in interfaceFuture<Void>
- Specified by:
await
in interfacePromise<Void>
- Overrides:
await
in classDefaultPromise<Void>
- Throws:
InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
Description copied from interface:Future
Waits for this future to be completed without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceChannelFuture
- Specified by:
awaitUninterruptibly
in interfaceChannelPromise
- Specified by:
awaitUninterruptibly
in interfaceFuture<Void>
- Specified by:
awaitUninterruptibly
in interfacePromise<Void>
- Overrides:
awaitUninterruptibly
in classDefaultPromise<Void>
-
flushCheckpoint
public long flushCheckpoint()- Specified by:
flushCheckpoint
in interfaceChannelFlushPromiseNotifier.FlushCheckpoint
-
flushCheckpoint
public void flushCheckpoint(long checkpoint) - Specified by:
flushCheckpoint
in interfaceChannelFlushPromiseNotifier.FlushCheckpoint
-
promise
- Specified by:
promise
in interfaceChannelFlushPromiseNotifier.FlushCheckpoint
-
checkDeadLock
protected void checkDeadLock()- Overrides:
checkDeadLock
in classDefaultPromise<Void>
-
unvoid
Description copied from interface:ChannelPromise
- Specified by:
unvoid
in interfaceChannelPromise
-
isVoid
public boolean isVoid()Description copied from interface:ChannelFuture
Returnstrue
if thisChannelFuture
is a void future and so not allow to call any of the following methods:- Specified by:
isVoid
in interfaceChannelFuture
-