Package cn.sliew.milky.concurrent
Class CompleteFuture<V>
- java.lang.Object
-
- cn.sliew.milky.concurrent.AbstractFuture<V>
-
- cn.sliew.milky.concurrent.CompleteFuture<V>
-
- Direct Known Subclasses:
FailedFuture,SucceededFuture
public abstract class CompleteFuture<V> extends AbstractFuture<V>
-
-
Constructor Summary
Constructors Constructor Description CompleteFuture()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Future<V>addListener(FutureListener<? extends Future<? super V>> listener)Adds the specified listener to this future.Future<V>await()Waits for this future to be completed.booleanawait(long timeout, TimeUnit unit)Waits for this future to be completed within the specified time limit.booleancancel(boolean mayInterruptIfRunning)booleanisCancelled()booleanisDone()Future<V>removeListener(FutureListener<? extends Future<? super V>> listener)Removes the first occurrence of the specified listener 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.-
Methods inherited from class cn.sliew.milky.concurrent.AbstractFuture
get, get
-
-
-
-
Method Detail
-
addListener
public Future<V> addListener(FutureListener<? extends Future<? super V>> listener)
Description copied from interface:FutureAdds 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.
-
removeListener
public Future<V> removeListener(FutureListener<? extends Future<? super V>> listener)
Description copied from interface:FutureRemoves 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.
-
sync
public Future<V> sync() throws InterruptedException
Description copied from interface:FutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.- Throws:
InterruptedException
-
await
public Future<V> await() throws InterruptedException
Description copied from interface:FutureWaits for this future to be completed.- Throws:
InterruptedException- if the current thread was interrupted
-
await
public boolean await(long timeout, TimeUnit unit) throws InterruptedExceptionDescription copied from interface:FutureWaits 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
-
isCancelled
public boolean isCancelled()
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
isDone
public boolean isDone()
-
-