Package io.netty.util.concurrent
Class DefaultProgressivePromise<V>
- java.lang.Object
-
- io.netty.util.concurrent.AbstractFuture<V>
-
- io.netty.util.concurrent.DefaultPromise<V>
-
- io.netty.util.concurrent.DefaultProgressivePromise<V>
-
- All Implemented Interfaces:
Future<V>
,ProgressiveFuture<V>
,ProgressivePromise<V>
,Promise<V>
,java.util.concurrent.Future<V>
- Direct Known Subclasses:
DefaultChannelProgressivePromise
public class DefaultProgressivePromise<V> extends DefaultPromise<V> implements ProgressivePromise<V>
-
-
Field Summary
-
Fields inherited from class io.netty.util.concurrent.DefaultPromise
PROPERTY_MAX_LISTENER_STACK_DEPTH
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultProgressivePromise()
DefaultProgressivePromise(EventExecutor executor)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProgressivePromise<V>
addListener(GenericFutureListener<? extends Future<? super V>> listener)
Adds the specified listener to this future.ProgressivePromise<V>
addListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
Adds the specified listeners to this future.ProgressivePromise<V>
await()
Waits for this future to be completed.ProgressivePromise<V>
awaitUninterruptibly()
Waits for this future to be completed without interruption.ProgressivePromise<V>
removeListener(GenericFutureListener<? extends Future<? super V>> listener)
Removes the first occurrence of the specified listener from this future.ProgressivePromise<V>
removeListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
Removes the first occurrence for each of the listeners from this future.ProgressivePromise<V>
setFailure(java.lang.Throwable cause)
Marks this future as a failure and notifies all listeners.ProgressivePromise<V>
setProgress(long progress, long total)
Sets the current progress of the operation and notifies the listeners that implementGenericProgressiveFutureListener
.ProgressivePromise<V>
setSuccess(V result)
Marks this future as a success and notifies all listeners.ProgressivePromise<V>
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.ProgressivePromise<V>
syncUninterruptibly()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.boolean
tryProgress(long progress, long total)
Tries to set the current progress of the operation and notifies the listeners that implementGenericProgressiveFutureListener
.-
Methods inherited from class io.netty.util.concurrent.DefaultPromise
await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, cause, checkDeadLock, executor, 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
-
DefaultProgressivePromise
public DefaultProgressivePromise(EventExecutor executor)
Creates a new instance. It is preferable to useEventExecutor.newProgressivePromise()
to create a new progressive promise- Parameters:
executor
- theEventExecutor
which is used to notify the promise when it progresses or it is complete
-
DefaultProgressivePromise
protected DefaultProgressivePromise()
-
-
Method Detail
-
setProgress
public ProgressivePromise<V> 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 interfaceProgressivePromise<V>
-
tryProgress
public boolean tryProgress(long progress, long total)
Description copied from interface:ProgressivePromise
Tries to set the current progress of the operation and notifies the listeners that implementGenericProgressiveFutureListener
. If the operation is already complete or the progress is out of range, this method does nothing but returningfalse
.- Specified by:
tryProgress
in interfaceProgressivePromise<V>
-
addListener
public ProgressivePromise<V> addListener(GenericFutureListener<? extends Future<? super V>> 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 interfaceFuture<V>
- Specified by:
addListener
in interfaceProgressiveFuture<V>
- Specified by:
addListener
in interfaceProgressivePromise<V>
- Specified by:
addListener
in interfacePromise<V>
- Overrides:
addListener
in classDefaultPromise<V>
-
addListeners
public ProgressivePromise<V> addListeners(GenericFutureListener<? extends Future<? super V>>... 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 interfaceFuture<V>
- Specified by:
addListeners
in interfaceProgressiveFuture<V>
- Specified by:
addListeners
in interfaceProgressivePromise<V>
- Specified by:
addListeners
in interfacePromise<V>
- Overrides:
addListeners
in classDefaultPromise<V>
-
removeListener
public ProgressivePromise<V> removeListener(GenericFutureListener<? extends Future<? super V>> 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 interfaceFuture<V>
- Specified by:
removeListener
in interfaceProgressiveFuture<V>
- Specified by:
removeListener
in interfaceProgressivePromise<V>
- Specified by:
removeListener
in interfacePromise<V>
- Overrides:
removeListener
in classDefaultPromise<V>
-
removeListeners
public ProgressivePromise<V> removeListeners(GenericFutureListener<? extends Future<? super V>>... 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 interfaceFuture<V>
- Specified by:
removeListeners
in interfaceProgressiveFuture<V>
- Specified by:
removeListeners
in interfaceProgressivePromise<V>
- Specified by:
removeListeners
in interfacePromise<V>
- Overrides:
removeListeners
in classDefaultPromise<V>
-
sync
public ProgressivePromise<V> 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 interfaceFuture<V>
- Specified by:
sync
in interfaceProgressiveFuture<V>
- Specified by:
sync
in interfaceProgressivePromise<V>
- Specified by:
sync
in interfacePromise<V>
- Overrides:
sync
in classDefaultPromise<V>
- Throws:
java.lang.InterruptedException
-
syncUninterruptibly
public ProgressivePromise<V> 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 interfaceFuture<V>
- Specified by:
syncUninterruptibly
in interfaceProgressiveFuture<V>
- Specified by:
syncUninterruptibly
in interfaceProgressivePromise<V>
- Specified by:
syncUninterruptibly
in interfacePromise<V>
- Overrides:
syncUninterruptibly
in classDefaultPromise<V>
-
await
public ProgressivePromise<V> await() throws java.lang.InterruptedException
Description copied from interface:Future
Waits for this future to be completed.- Specified by:
await
in interfaceFuture<V>
- Specified by:
await
in interfaceProgressiveFuture<V>
- Specified by:
await
in interfaceProgressivePromise<V>
- Specified by:
await
in interfacePromise<V>
- Overrides:
await
in classDefaultPromise<V>
- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
public ProgressivePromise<V> 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 interfaceFuture<V>
- Specified by:
awaitUninterruptibly
in interfaceProgressiveFuture<V>
- Specified by:
awaitUninterruptibly
in interfaceProgressivePromise<V>
- Specified by:
awaitUninterruptibly
in interfacePromise<V>
- Overrides:
awaitUninterruptibly
in classDefaultPromise<V>
-
setSuccess
public ProgressivePromise<V> setSuccess(V 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 interfaceProgressivePromise<V>
- Specified by:
setSuccess
in interfacePromise<V>
- Overrides:
setSuccess
in classDefaultPromise<V>
-
setFailure
public ProgressivePromise<V> 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 interfaceProgressivePromise<V>
- Specified by:
setFailure
in interfacePromise<V>
- Overrides:
setFailure
in classDefaultPromise<V>
-
-