final class VoidChannelPromise extends AbstractFuture<java.lang.Void> implements ChannelPromise
Modifier and Type | Field and Description |
---|---|
private Channel |
channel |
private boolean |
fireException |
Constructor and Description |
---|
VoidChannelPromise(Channel channel,
boolean fireException)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
VoidChannelPromise |
addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Adds the specified listener to this future.
|
VoidChannelPromise |
addListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Adds the specified listeners to this future.
|
VoidChannelPromise |
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.
|
VoidChannelPromise |
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 an
CancellationException . |
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.
|
private static void |
fail() |
private void |
fireException(java.lang.Throwable cause) |
java.lang.Void |
getNow()
Return the result without blocking.
|
boolean |
isCancellable()
returns
true if and only if the operation can be cancelled via Future.cancel(boolean) . |
boolean |
isCancelled() |
boolean |
isDone() |
boolean |
isSuccess()
Returns
true if and only if the I/O operation was completed
successfully. |
VoidChannelPromise |
removeListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Removes the first occurrence of the specified listener from this future.
|
VoidChannelPromise |
removeListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Removes the first occurrence for each of the listeners from this future.
|
VoidChannelPromise |
setFailure(java.lang.Throwable cause)
Marks this future as a failure and notifies all
listeners.
|
VoidChannelPromise |
setSuccess() |
VoidChannelPromise |
setSuccess(java.lang.Void result)
Marks this future as a success and notifies all
listeners.
|
boolean |
setUncancellable()
Make this future impossible to cancel.
|
VoidChannelPromise |
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future
failed.
|
VoidChannelPromise |
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.
|
get, get
private final Channel channel
private final boolean fireException
public VoidChannelPromise addListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Future
addListener
in interface ChannelFuture
addListener
in interface ChannelPromise
addListener
in interface Promise<java.lang.Void>
public VoidChannelPromise addListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Future
addListeners
in interface ChannelFuture
addListeners
in interface ChannelPromise
addListeners
in interface Promise<java.lang.Void>
public VoidChannelPromise removeListener(GenericFutureListener<? extends Future<? super java.lang.Void>> listener)
Future
removeListener
in interface ChannelFuture
removeListener
in interface ChannelPromise
removeListener
in interface Promise<java.lang.Void>
public VoidChannelPromise removeListeners(GenericFutureListener<? extends Future<? super java.lang.Void>>... listeners)
Future
removeListeners
in interface ChannelFuture
removeListeners
in interface ChannelPromise
removeListeners
in interface Promise<java.lang.Void>
public VoidChannelPromise await() throws java.lang.InterruptedException
Future
await
in interface ChannelFuture
await
in interface ChannelPromise
await
in interface Promise<java.lang.Void>
java.lang.InterruptedException
- if the current thread was interruptedpublic boolean await(long timeout, java.util.concurrent.TimeUnit unit)
Future
true
if and only if the future was completed within
the specified time limitpublic boolean await(long timeoutMillis)
Future
true
if and only if the future was completed within
the specified time limitpublic VoidChannelPromise awaitUninterruptibly()
Future
InterruptedException
and
discards it silently.awaitUninterruptibly
in interface ChannelFuture
awaitUninterruptibly
in interface ChannelPromise
awaitUninterruptibly
in interface Promise<java.lang.Void>
public boolean awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)
Future
InterruptedException
and discards it silently.true
if and only if the future was completed within
the specified time limitpublic boolean awaitUninterruptibly(long timeoutMillis)
Future
InterruptedException
and discards it silently.true
if and only if the future was completed within
the specified time limitpublic Channel channel()
ChannelFuture
channel
in interface ChannelFuture
channel
in interface ChannelPromise
public boolean isDone()
isDone
in interface java.util.concurrent.Future<java.lang.Void>
public boolean isSuccess()
Future
true
if and only if the I/O operation was completed
successfully.public boolean setUncancellable()
Promise
setUncancellable
in interface Promise<java.lang.Void>
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.public boolean isCancellable()
Future
true
if and only if the operation can be cancelled via Future.cancel(boolean)
.public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<java.lang.Void>
public java.lang.Throwable cause()
Future
null
if succeeded or this future is not
completed yet.public VoidChannelPromise sync()
Future
sync
in interface ChannelFuture
sync
in interface ChannelPromise
sync
in interface Promise<java.lang.Void>
public VoidChannelPromise syncUninterruptibly()
Future
syncUninterruptibly
in interface ChannelFuture
syncUninterruptibly
in interface ChannelPromise
syncUninterruptibly
in interface Promise<java.lang.Void>
public VoidChannelPromise setFailure(java.lang.Throwable cause)
Promise
IllegalStateException
.setFailure
in interface ChannelPromise
setFailure
in interface Promise<java.lang.Void>
public VoidChannelPromise setSuccess()
setSuccess
in interface ChannelPromise
public boolean tryFailure(java.lang.Throwable cause)
Promise
tryFailure
in interface Promise<java.lang.Void>
true
if and only if successfully marked this future as
a failure. Otherwise false
because this future is
already marked as either a success or a failure.public boolean cancel(boolean mayInterruptIfRunning)
Future
CancellationException
.cancel
in interface java.util.concurrent.Future<java.lang.Void>
public boolean trySuccess()
trySuccess
in interface ChannelPromise
private static void fail()
public VoidChannelPromise setSuccess(java.lang.Void result)
Promise
IllegalStateException
.setSuccess
in interface ChannelPromise
setSuccess
in interface Promise<java.lang.Void>
public boolean trySuccess(java.lang.Void result)
Promise
trySuccess
in interface Promise<java.lang.Void>
true
if and only if successfully marked this future as
a success. Otherwise false
because this future is
already marked as either a success or a failure.public java.lang.Void getNow()
Future
null
.
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 with Future.isDone()
and not relay on the returned null
value.private void fireException(java.lang.Throwable cause)