Package cn.sliew.milky.concurrent
Class FailedFuture<V>
- java.lang.Object
-
- cn.sliew.milky.concurrent.AbstractFuture<V>
-
- cn.sliew.milky.concurrent.CompleteFuture<V>
-
- cn.sliew.milky.concurrent.FailedFuture<V>
-
public class FailedFuture<V> extends CompleteFuture<V>
TheCompleteFuturewhich is failed already.
-
-
Constructor Summary
Constructors Constructor Description FailedFuture(Throwable cause)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Throwablecause()Returns the cause of the failed operation if the operation has failed.VgetNow()Return the result without blocking.booleanisSuccess()Returnstrueif and only if the operation was completed successfully.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.CompleteFuture
addListener, await, await, cancel, isCancelled, isDone, removeListener
-
Methods inherited from class cn.sliew.milky.concurrent.AbstractFuture
get, get
-
-
-
-
Constructor Detail
-
FailedFuture
public FailedFuture(Throwable cause)
-
-
Method Detail
-
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.- Specified by:
syncin interfaceFuture<V>- Overrides:
syncin classCompleteFuture<V>- Throws:
InterruptedException
-
isSuccess
public boolean isSuccess()
Description copied from interface:FutureReturnstrueif and only if the operation was completed successfully.
-
cause
public Throwable cause()
Description copied from interface:FutureReturns the cause of the failed operation if the operation has failed.- Returns:
- the cause of the failure.
nullif succeeded or this future is not completed yet.
-
getNow
public V getNow()
Description copied from interface:FutureReturn 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 relay on the returnednullvalue.
-
-