Package com.google.code.yanf4j.core.impl
Class FutureImpl<R>
- java.lang.Object
-
- com.google.code.yanf4j.core.impl.FutureImpl<R>
-
-
Constructor Summary
Constructors Constructor Description FutureImpl()FutureImpl(Object sync)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)voidfailure(Throwable failure)Notify about the failure, occured during asynchronous operation execution.Rget()Rget(long timeout, TimeUnit unit)RgetResult()Get current result value without any blocking.booleanisCancelled()booleanisDone()protected voidnotifyHaveResult()Notify blocked listeners threads about operation completion.voidsetResult(R result)Set the result value and notify about operation completion.
-
-
-
Field Detail
-
result
protected R result
-
-
Constructor Detail
-
FutureImpl
public FutureImpl()
-
FutureImpl
public FutureImpl(Object sync)
-
-
Method Detail
-
getResult
public R getResult()
Get current result value without any blocking.- Returns:
- current result value without any blocking.
-
setResult
public void setResult(R result)
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>
-
get
public R get() throws InterruptedException, ExecutionException
- 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
public void failure(Throwable failure)
Notify about the failure, occured during asynchronous operation execution.- Parameters:
failure-
-
notifyHaveResult
protected void notifyHaveResult()
Notify blocked listeners threads about operation completion.
-
-