Package io.netty.util.concurrent
Interface Future<V>
-
- All Superinterfaces:
java.util.concurrent.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
public interface Future<V> extends java.util.concurrent.Future<V>
The result of an asynchronous operation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Future<V>
addListener(GenericFutureListener<? extends Future<? super V>> listener)
Adds the specified listener to this future.Future<V>
addListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
Adds the specified listeners to this future.Future<V>
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.Future<V>
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.V
getNow()
Return the result without blocking.boolean
isCancellable()
returnstrue
if and only if the operation can be cancelled viacancel(boolean)
.boolean
isSuccess()
Returnstrue
if and only if the I/O operation was completed successfully.Future<V>
removeListener(GenericFutureListener<? extends Future<? super V>> listener)
Removes the first occurrence of the specified listener from this future.Future<V>
removeListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
Removes the first occurrence for each of the listeners from this future.Future<V>
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.Future<V>
syncUninterruptibly()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
-
-
-
Method Detail
-
isSuccess
boolean isSuccess()
Returnstrue
if and only if the I/O operation was completed successfully.
-
isCancellable
boolean isCancellable()
returnstrue
if and only if the operation can be cancelled viacancel(boolean)
.
-
cause
java.lang.Throwable cause()
Returns the cause of the failed I/O operation if the I/O operation has failed.- Returns:
- the cause of the failure.
null
if succeeded or this future is not completed yet.
-
addListener
Future<V> addListener(GenericFutureListener<? extends Future<? super V>> listener)
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.
-
addListeners
Future<V> addListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
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.
-
removeListener
Future<V> removeListener(GenericFutureListener<? extends Future<? super V>> listener)
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
Future<V> removeListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
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
Future<V> sync() throws java.lang.InterruptedException
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.- Throws:
java.lang.InterruptedException
-
syncUninterruptibly
Future<V> syncUninterruptibly()
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
-
await
Future<V> await() throws java.lang.InterruptedException
Waits for this future to be completed.- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
Future<V> awaitUninterruptibly()
Waits for this future to be completed without interruption. This method catches anInterruptedException
and discards it silently.
-
await
boolean await(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Waits for this future to be completed within the specified time limit.- Returns:
true
if and only if the future was completed within the specified time limit- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
await
boolean await(long timeoutMillis) throws java.lang.InterruptedException
Waits for this future to be completed within the specified time limit.- Returns:
true
if and only if the future was completed within the specified time limit- Throws:
java.lang.InterruptedException
- if the current thread was interrupted
-
awaitUninterruptibly
boolean awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedException
and discards it silently.- Returns:
true
if 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 anInterruptedException
and discards it silently.- Returns:
true
if 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
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
boolean cancel(boolean mayInterruptIfRunning)
If the cancellation was successful it will fail the future with aCancellationException
.- Specified by:
cancel
in interfacejava.util.concurrent.Future<V>
-
-