Class FutureLockImpl<R>
java.lang.Object
com.google.code.yanf4j.core.impl.FutureLockImpl<R>
- All Implemented Interfaces:
Future<R>
Simple
Future implementation, which uses ReentrantLock to synchronize during the
lifecycle.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Future
Future.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Throwableprivate booleanprivate booleanprivate CountDownLatchprivate final ReentrantLockprotected R -
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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Future
exceptionNow, resultNow, state
-
Field Details
-
lock
-
isDone
private boolean isDone -
latch
-
isCancelled
private boolean isCancelled -
failure
-
result
-
-
Constructor Details
-
FutureLockImpl
public FutureLockImpl() -
FutureLockImpl
-
-
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
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<R>
-
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.
-