Package com.google.code.yanf4j.core.impl
Class FutureImpl<R>
java.lang.Object
com.google.code.yanf4j.core.impl.FutureImpl<R>
- All Implemented Interfaces:
Future<R>
- Direct Known Subclasses:
ConnectFuture
Simple
Future
implementation, which uses synchronization Object
to synchronize
during the lifecycle.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel
(boolean mayInterruptIfRunning) void
Notify about the failure, occured during asynchronous operation execution.get()
Get current result value without any blocking.boolean
boolean
isDone()
protected void
Notify blocked listeners threads about operation completion.void
Set the result value and notify about operation completion.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Field Details
-
sync
-
isDone
private boolean isDone -
isCancelled
private boolean isCancelled -
failure
-
result
-
-
Constructor Details
-
FutureImpl
public FutureImpl() -
FutureImpl
-
-
Method Details
-
getResult
Get current result value without any blocking.- Returns:
- current result value without any blocking.
-
setResult
Set the result value and notify about operation completion.- Parameters:
result
- the result value
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in interfaceFuture<R>
-
isDone
public boolean isDone() -
get
- Specified by:
get
in interfaceFuture<R>
- Throws:
InterruptedException
ExecutionException
-
get
public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
get
in interfaceFuture<R>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
failure
Notify about the failure, occured during asynchronous operation execution.- Parameters:
failure
-
-
notifyHaveResult
protected void notifyHaveResult()Notify blocked listeners threads about operation completion.
-