Interface Future<V>
- All Superinterfaces:
Future<V>
- All Known Subinterfaces:
ChannelFuture, ChannelGroupFuture, ChannelProgressiveFuture, ChannelProgressivePromise, ChannelPromise, ProgressiveFuture<V>, ProgressivePromise<V>, Promise<V>, ScheduledFuture<V>
- All Known Implementing Classes:
AbstractFuture, CompleteFuture, DefaultChannelProgressivePromise, DefaultChannelPromise, DefaultProgressivePromise, DefaultPromise, DelegatingChannelPromiseNotifier, FailedFuture, SucceededFuture, VoidChannelPromise
The result of an asynchronous operation.
-
Method Summary
Modifier and TypeMethodDescriptionaddListener(GenericFutureListener<? extends Future<? super V>> listener) Adds the specified listener to this future.addListeners(GenericFutureListener<? extends Future<? super V>>... listeners) Adds the specified listeners to this future.await()Waits for this future to be completed.booleanawait(long timeoutMillis) Waits for this future to be completed within the specified time limit.booleanWaits for this future to be completed within the specified time limit.Waits for this future to be completed without interruption.booleanawaitUninterruptibly(long timeoutMillis) Waits for this future to be completed within the specified time limit without interruption.booleanawaitUninterruptibly(long timeout, TimeUnit unit) Waits for this future to be completed within the specified time limit without interruption.booleancancel(boolean mayInterruptIfRunning) If the cancellation was successful it will fail the future with aCancellationException.cause()Returns the cause of the failed I/O operation if the I/O operation has failed.getNow()Return the result without blocking.booleanreturnstrueif and only if the operation can be cancelled viacancel(boolean).booleanReturnstrueif and only if the I/O operation was completed successfully.removeListener(GenericFutureListener<? extends Future<? super V>> listener) Removes the first occurrence of the specified listener from this future.removeListeners(GenericFutureListener<? extends Future<? super V>>... listeners) Removes the first occurrence for each of the listeners from this future.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.Methods inherited from interface Future
get, get, isCancelled, isDone
-
Method Details
-
isSuccess
boolean isSuccess()Returnstrueif and only if the I/O operation was completed successfully. -
isCancellable
boolean isCancellable()returnstrueif and only if the operation can be cancelled viacancel(boolean). -
cause
Throwable cause()Returns the cause of the failed I/O operation if the I/O operation has failed.- Returns:
- the cause of the failure.
nullif succeeded or this future is not completed yet.
-
addListener
-
addListeners
-
removeListener
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. -
removeListeners
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. -
sync
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.- Throws:
InterruptedException
-
syncUninterruptibly
-
await
Waits for this future to be completed.- Throws:
InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
Waits for this future to be completed without interruption. This method catches anInterruptedExceptionand discards it silently. -
await
Waits for this future to be completed within the specified time limit.- Returns:
trueif and only if the future was completed within the specified time limit- Throws:
InterruptedException- if the current thread was interrupted
-
await
Waits for this future to be completed within the specified time limit.- Returns:
trueif and only if the future was completed within the specified time limit- Throws:
InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Returns:
trueif and only if the future was completed within the specified time limit
-
awaitUninterruptibly
boolean awaitUninterruptibly(long timeoutMillis) Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Returns:
trueif and only if the future was completed within the specified time limit
-
getNow
V getNow()Return the result without blocking. If the future is not done yet this will returnnull.As it is possible that a
nullvalue 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 returnednullvalue. -
cancel
boolean cancel(boolean mayInterruptIfRunning) If the cancellation was successful it will fail the future with aCancellationException.
-