Package io.netty.channel
Class DelegatingChannelPromiseNotifier
- java.lang.Object
-
- io.netty.channel.DelegatingChannelPromiseNotifier
-
- All Implemented Interfaces:
ChannelFuture
,ChannelFutureListener
,ChannelPromise
,Future<java.lang.Void>
,GenericFutureListener<ChannelFuture>
,Promise<java.lang.Void>
,java.util.concurrent.Future<java.lang.Void>
,java.util.EventListener
@UnstableApi public final class DelegatingChannelPromiseNotifier extends java.lang.Object implements ChannelPromise, ChannelFutureListener
-
-
Field Summary
-
Fields inherited from interface io.netty.channel.ChannelFutureListener
CLOSE, CLOSE_ON_FAILURE, FIRE_EXCEPTION_ON_FAILURE
-
-
Constructor Summary
Constructors Constructor Description DelegatingChannelPromiseNotifier(ChannelPromise delegate)
DelegatingChannelPromiseNotifier(ChannelPromise delegate, boolean logNotifyFailure)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelPromise
addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Adds the specified listener to this future.ChannelPromise
addListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Adds the specified listeners to this future.ChannelPromise
await()
Waits for this future to be completed.boolean
await(long timeoutMillis)
Waits for this future to be completed within the specified time limit.boolean
await(long timeout, java.util.concurrent.TimeUnit unit)
Waits for this future to be completed within the specified time limit.ChannelPromise
awaitUninterruptibly()
Waits for this future to be completed without interruption.boolean
awaitUninterruptibly(long timeoutMillis)
Waits for this future to be completed within the specified time limit without interruption.boolean
awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)
Waits for this future to be completed within the specified time limit without interruption.boolean
cancel(boolean mayInterruptIfRunning)
If the cancellation was successful it will fail the future with aCancellationException
.java.lang.Throwable
cause()
Returns the cause of the failed I/O operation if the I/O operation has failed.Channel
channel()
Returns a channel where the I/O operation associated with this future takes place.java.lang.Void
get()
java.lang.Void
get(long timeout, java.util.concurrent.TimeUnit unit)
java.lang.Void
getNow()
Return the result without blocking.boolean
isCancellable()
returnstrue
if and only if the operation can be cancelled viaFuture.cancel(boolean)
.boolean
isCancelled()
boolean
isDone()
boolean
isSuccess()
Returnstrue
if and only if the I/O operation was completed successfully.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()
void
operationComplete(ChannelFuture future)
Invoked when the operation associated with theFuture
has been completed.ChannelPromise
removeListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Removes the first occurrence of the specified listener from this future.ChannelPromise
removeListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Removes the first occurrence for each of the listeners from this future.ChannelPromise
setFailure(java.lang.Throwable cause)
Marks this future as a failure and notifies all listeners.ChannelPromise
setSuccess()
ChannelPromise
setSuccess(java.lang.Void result)
Marks this future as a success and notifies all listeners.boolean
setUncancellable()
Make this future impossible to cancel.ChannelPromise
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.ChannelPromise
syncUninterruptibly()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.boolean
tryFailure(java.lang.Throwable cause)
Marks this future as a failure and notifies all listeners.boolean
trySuccess()
boolean
trySuccess(java.lang.Void result)
Marks this future as a success and notifies all listeners.ChannelPromise
unvoid()
-
-
-
Constructor Detail
-
DelegatingChannelPromiseNotifier
public DelegatingChannelPromiseNotifier(ChannelPromise delegate)
-
DelegatingChannelPromiseNotifier
public DelegatingChannelPromiseNotifier(ChannelPromise delegate, boolean logNotifyFailure)
-
-
Method Detail
-
operationComplete
public void operationComplete(ChannelFuture future) throws java.lang.Exception
Description copied from interface:GenericFutureListener
Invoked when the operation associated with theFuture
has been completed.- Specified by:
operationComplete
in interfaceGenericFutureListener<ChannelFuture>
- Parameters:
future
- the sourceFuture
which called this callback- Throws:
java.lang.Exception
-
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 ChannelPromise 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 interfaceChannelPromise
- Specified by:
setSuccess
in interfacePromise<java.lang.Void>
-
setSuccess
public ChannelPromise setSuccess()
- Specified by:
setSuccess
in interfaceChannelPromise
-
trySuccess
public boolean trySuccess()
- Specified by:
trySuccess
in interfaceChannelPromise
-
trySuccess
public boolean trySuccess(java.lang.Void result)
Description copied from interface:Promise
Marks this future as a success and notifies all listeners.- Specified by:
trySuccess
in interfacePromise<java.lang.Void>
- Returns:
true
if and only if successfully marked this future as a success. Otherwisefalse
because this future is already marked as either a success or a failure.
-
setFailure
public ChannelPromise 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 interfaceChannelPromise
- Specified by:
setFailure
in interfacePromise<java.lang.Void>
-
addListener
public ChannelPromise 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 interfaceChannelPromise
- Specified by:
addListener
in interfaceFuture<java.lang.Void>
- Specified by:
addListener
in interfacePromise<java.lang.Void>
-
addListeners
public ChannelPromise 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 interfaceChannelPromise
- Specified by:
addListeners
in interfaceFuture<java.lang.Void>
- Specified by:
addListeners
in interfacePromise<java.lang.Void>
-
removeListener
public ChannelPromise 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 interfaceChannelPromise
- Specified by:
removeListener
in interfaceFuture<java.lang.Void>
- Specified by:
removeListener
in interfacePromise<java.lang.Void>
-
removeListeners
public ChannelPromise 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 interfaceChannelPromise
- Specified by:
removeListeners
in interfaceFuture<java.lang.Void>
- Specified by:
removeListeners
in interfacePromise<java.lang.Void>
-
tryFailure
public boolean tryFailure(java.lang.Throwable cause)
Description copied from interface:Promise
Marks this future as a failure and notifies all listeners.- Specified by:
tryFailure
in interfacePromise<java.lang.Void>
- Returns:
true
if and only if successfully marked this future as a failure. Otherwisefalse
because this future is already marked as either a success or a failure.
-
setUncancellable
public boolean setUncancellable()
Description copied from interface:Promise
Make this future impossible to cancel.- Specified by:
setUncancellable
in interfacePromise<java.lang.Void>
- Returns:
true
if and only if successfully marked this future as uncancellable or it is already done without being cancelled.false
if this future has been cancelled already.
-
await
public ChannelPromise 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 interfaceChannelPromise
- Specified by:
await
in interfaceFuture<java.lang.Void>
- Specified by:
await
in interfacePromise<java.lang.Void>
- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
public ChannelPromise 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<java.lang.Void>
- Specified by:
awaitUninterruptibly
in interfacePromise<java.lang.Void>
-
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
-
unvoid
public ChannelPromise unvoid()
Description copied from interface:ChannelPromise
- Specified by:
unvoid
in interfaceChannelPromise
-
await
public boolean await(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Description copied from interface:Future
Waits for this future to be completed within the specified time limit.
-
await
public boolean await(long timeoutMillis) throws java.lang.InterruptedException
Description copied from interface:Future
Waits for this future to be completed within the specified time limit.
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)
Description copied from interface:Future
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceFuture<java.lang.Void>
- Returns:
true
if and only if the future was completed within the specified time limit
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis)
Description copied from interface:Future
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceFuture<java.lang.Void>
- Returns:
true
if and only if the future was completed within the specified time limit
-
getNow
public java.lang.Void getNow()
Description copied from interface:Future
Return the result without blocking. If the future is not done yet this will returnnull
.As it is possible that a
null
value 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 returnednull
value.
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
Description copied from interface:Future
If the cancellation was successful it will fail the future with aCancellationException
.
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<java.lang.Void>
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<java.lang.Void>
-
get
public java.lang.Void get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
get
in interfacejava.util.concurrent.Future<java.lang.Void>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
get
public java.lang.Void get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
get
in interfacejava.util.concurrent.Future<java.lang.Void>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
sync
public ChannelPromise 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 interfaceChannelPromise
- Specified by:
sync
in interfaceFuture<java.lang.Void>
- Specified by:
sync
in interfacePromise<java.lang.Void>
- Throws:
java.lang.InterruptedException
-
syncUninterruptibly
public ChannelPromise 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<java.lang.Void>
- Specified by:
syncUninterruptibly
in interfacePromise<java.lang.Void>
-
isSuccess
public boolean isSuccess()
Description copied from interface:Future
Returnstrue
if and only if the I/O operation was completed successfully.
-
isCancellable
public boolean isCancellable()
Description copied from interface:Future
returnstrue
if and only if the operation can be cancelled viaFuture.cancel(boolean)
.- Specified by:
isCancellable
in interfaceFuture<java.lang.Void>
-
cause
public java.lang.Throwable cause()
Description copied from interface:Future
Returns the cause of the failed I/O operation if the I/O operation has failed.
-
-