Package io.netty.channel
Class DefaultChannelProgressivePromise
- java.lang.Object
-
- io.netty.util.concurrent.AbstractFuture<V>
-
- io.netty.util.concurrent.DefaultPromise<V>
-
- io.netty.util.concurrent.DefaultProgressivePromise<java.lang.Void>
-
- io.netty.channel.DefaultChannelProgressivePromise
-
- All Implemented Interfaces:
ChannelFuture
,ChannelProgressiveFuture
,ChannelProgressivePromise
,ChannelPromise
,Future<java.lang.Void>
,ProgressiveFuture<java.lang.Void>
,ProgressivePromise<java.lang.Void>
,Promise<java.lang.Void>
,java.util.concurrent.Future<java.lang.Void>
public class DefaultChannelProgressivePromise extends DefaultProgressivePromise<java.lang.Void> implements ChannelProgressivePromise
The defaultChannelProgressivePromise
implementation. It is recommended to useChannel.newProgressivePromise()
to create a newChannelProgressivePromise
rather 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 DefaultChannelProgressivePromise(Channel channel)
Creates a new instance.DefaultChannelProgressivePromise(Channel channel, EventExecutor executor)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelProgressivePromise
addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Adds the specified listener to this future.ChannelProgressivePromise
addListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Adds the specified listeners to this future.ChannelProgressivePromise
await()
Waits for this future to be completed.ChannelProgressivePromise
awaitUninterruptibly()
Waits for this future to be completed without interruption.Channel
channel()
Returns a channel where the I/O operation associated with this future takes place.protected void
checkDeadLock()
protected EventExecutor
executor()
Get the executor used to notify listeners when this promise is complete.long
flushCheckpoint()
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()
ChannelProgressivePromise
promise()
ChannelProgressivePromise
removeListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Removes the first occurrence of the specified listener from this future.ChannelProgressivePromise
removeListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Removes the first occurrence for each of the listeners from this future.ChannelProgressivePromise
setFailure(java.lang.Throwable cause)
Marks this future as a failure and notifies all listeners.ChannelProgressivePromise
setProgress(long progress, long total)
Sets the current progress of the operation and notifies the listeners that implementGenericProgressiveFutureListener
.ChannelProgressivePromise
setSuccess()
ChannelProgressivePromise
setSuccess(java.lang.Void result)
Marks this future as a success and notifies all listeners.ChannelProgressivePromise
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.ChannelProgressivePromise
syncUninterruptibly()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.boolean
trySuccess()
ChannelProgressivePromise
unvoid()
-
Methods inherited from class io.netty.util.concurrent.DefaultProgressivePromise
tryProgress
-
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.ProgressivePromise
tryProgress
-
Methods inherited from interface io.netty.util.concurrent.Promise
setUncancellable, tryFailure, trySuccess
-
-
-
-
Constructor Detail
-
DefaultChannelProgressivePromise
public DefaultChannelProgressivePromise(Channel channel)
Creates a new instance.- Parameters:
channel
- theChannel
associated with this future
-
DefaultChannelProgressivePromise
public DefaultChannelProgressivePromise(Channel channel, EventExecutor executor)
Creates a new instance.- Parameters:
channel
- theChannel
associated with this future
-
-
Method Detail
-
executor
protected EventExecutor 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<java.lang.Void>
- Returns:
- The executor used to notify listeners when this promise is complete.
-
channel
public Channel 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
public ChannelProgressivePromise setSuccess()
- Specified by:
setSuccess
in interfaceChannelProgressivePromise
- Specified by:
setSuccess
in interfaceChannelPromise
-
setSuccess
public ChannelProgressivePromise setSuccess(java.lang.Void result)
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 interfaceChannelProgressivePromise
- Specified by:
setSuccess
in interfaceChannelPromise
- Specified by:
setSuccess
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
setSuccess
in interfacePromise<java.lang.Void>
- Overrides:
setSuccess
in classDefaultProgressivePromise<java.lang.Void>
-
trySuccess
public boolean trySuccess()
- Specified by:
trySuccess
in interfaceChannelPromise
-
setFailure
public ChannelProgressivePromise setFailure(java.lang.Throwable cause)
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 interfaceChannelProgressivePromise
- Specified by:
setFailure
in interfaceChannelPromise
- Specified by:
setFailure
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
setFailure
in interfacePromise<java.lang.Void>
- Overrides:
setFailure
in classDefaultProgressivePromise<java.lang.Void>
-
setProgress
public ChannelProgressivePromise setProgress(long progress, long total)
Description copied from interface:ProgressivePromise
Sets the current progress of the operation and notifies the listeners that implementGenericProgressiveFutureListener
.- Specified by:
setProgress
in interfaceChannelProgressivePromise
- Specified by:
setProgress
in interfaceProgressivePromise<java.lang.Void>
- Overrides:
setProgress
in classDefaultProgressivePromise<java.lang.Void>
-
addListener
public ChannelProgressivePromise addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
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 interfaceChannelProgressiveFuture
- Specified by:
addListener
in interfaceChannelProgressivePromise
- Specified by:
addListener
in interfaceChannelPromise
- Specified by:
addListener
in interfaceFuture<java.lang.Void>
- Specified by:
addListener
in interfaceProgressiveFuture<java.lang.Void>
- Specified by:
addListener
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
addListener
in interfacePromise<java.lang.Void>
- Overrides:
addListener
in classDefaultProgressivePromise<java.lang.Void>
-
addListeners
public ChannelProgressivePromise addListeners(GenericFutureListener<? extends Future<? super java.lang.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 interfaceChannelProgressiveFuture
- Specified by:
addListeners
in interfaceChannelProgressivePromise
- Specified by:
addListeners
in interfaceChannelPromise
- Specified by:
addListeners
in interfaceFuture<java.lang.Void>
- Specified by:
addListeners
in interfaceProgressiveFuture<java.lang.Void>
- Specified by:
addListeners
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
addListeners
in interfacePromise<java.lang.Void>
- Overrides:
addListeners
in classDefaultProgressivePromise<java.lang.Void>
-
removeListener
public ChannelProgressivePromise removeListener(GenericFutureListener<? extends Future<? super java.lang.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 interfaceChannelProgressiveFuture
- Specified by:
removeListener
in interfaceChannelProgressivePromise
- Specified by:
removeListener
in interfaceChannelPromise
- Specified by:
removeListener
in interfaceFuture<java.lang.Void>
- Specified by:
removeListener
in interfaceProgressiveFuture<java.lang.Void>
- Specified by:
removeListener
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
removeListener
in interfacePromise<java.lang.Void>
- Overrides:
removeListener
in classDefaultProgressivePromise<java.lang.Void>
-
removeListeners
public ChannelProgressivePromise removeListeners(GenericFutureListener<? extends Future<? super java.lang.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 interfaceChannelProgressiveFuture
- Specified by:
removeListeners
in interfaceChannelProgressivePromise
- Specified by:
removeListeners
in interfaceChannelPromise
- Specified by:
removeListeners
in interfaceFuture<java.lang.Void>
- Specified by:
removeListeners
in interfaceProgressiveFuture<java.lang.Void>
- Specified by:
removeListeners
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
removeListeners
in interfacePromise<java.lang.Void>
- Overrides:
removeListeners
in classDefaultProgressivePromise<java.lang.Void>
-
sync
public ChannelProgressivePromise sync() throws java.lang.InterruptedException
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 interfaceChannelProgressiveFuture
- Specified by:
sync
in interfaceChannelProgressivePromise
- Specified by:
sync
in interfaceChannelPromise
- Specified by:
sync
in interfaceFuture<java.lang.Void>
- Specified by:
sync
in interfaceProgressiveFuture<java.lang.Void>
- Specified by:
sync
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
sync
in interfacePromise<java.lang.Void>
- Overrides:
sync
in classDefaultProgressivePromise<java.lang.Void>
- Throws:
java.lang.InterruptedException
-
syncUninterruptibly
public ChannelProgressivePromise 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 interfaceChannelProgressiveFuture
- Specified by:
syncUninterruptibly
in interfaceChannelProgressivePromise
- Specified by:
syncUninterruptibly
in interfaceChannelPromise
- Specified by:
syncUninterruptibly
in interfaceFuture<java.lang.Void>
- Specified by:
syncUninterruptibly
in interfaceProgressiveFuture<java.lang.Void>
- Specified by:
syncUninterruptibly
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
syncUninterruptibly
in interfacePromise<java.lang.Void>
- Overrides:
syncUninterruptibly
in classDefaultProgressivePromise<java.lang.Void>
-
await
public ChannelProgressivePromise await() throws java.lang.InterruptedException
Description copied from interface:Future
Waits for this future to be completed.- Specified by:
await
in interfaceChannelFuture
- Specified by:
await
in interfaceChannelProgressiveFuture
- Specified by:
await
in interfaceChannelProgressivePromise
- Specified by:
await
in interfaceChannelPromise
- Specified by:
await
in interfaceFuture<java.lang.Void>
- Specified by:
await
in interfaceProgressiveFuture<java.lang.Void>
- Specified by:
await
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
await
in interfacePromise<java.lang.Void>
- Overrides:
await
in classDefaultProgressivePromise<java.lang.Void>
- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
public ChannelProgressivePromise 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 interfaceChannelProgressiveFuture
- Specified by:
awaitUninterruptibly
in interfaceChannelProgressivePromise
- Specified by:
awaitUninterruptibly
in interfaceChannelPromise
- Specified by:
awaitUninterruptibly
in interfaceFuture<java.lang.Void>
- Specified by:
awaitUninterruptibly
in interfaceProgressiveFuture<java.lang.Void>
- Specified by:
awaitUninterruptibly
in interfaceProgressivePromise<java.lang.Void>
- Specified by:
awaitUninterruptibly
in interfacePromise<java.lang.Void>
- Overrides:
awaitUninterruptibly
in classDefaultProgressivePromise<java.lang.Void>
-
flushCheckpoint
public long flushCheckpoint()
-
flushCheckpoint
public void flushCheckpoint(long checkpoint)
-
promise
public ChannelProgressivePromise promise()
-
checkDeadLock
protected void checkDeadLock()
- Overrides:
checkDeadLock
in classDefaultPromise<java.lang.Void>
-
unvoid
public ChannelProgressivePromise unvoid()
Description copied from interface:ChannelPromise
- Specified by:
unvoid
in interfaceChannelProgressivePromise
- 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
-
-