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 TypeMethodDescriptionbooleancancel(boolean mayInterruptIfRunning) voidNotify about the failure, occured during asynchronous operation execution.get()Get current result value without any blocking.booleanbooleanisDone()protected voidNotify blocked listeners threads about operation completion.voidSet 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, waitMethods 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:
isCancelledin interfaceFuture<R>
-
isDone
public boolean isDone() -
get
- Specified by:
getin interfaceFuture<R>- Throws:
InterruptedExceptionExecutionException
-
get
public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
getin interfaceFuture<R>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
failure
Notify about the failure, occured during asynchronous operation execution.- Parameters:
failure-
-
notifyHaveResult
protected void notifyHaveResult()Notify blocked listeners threads about operation completion.
-