Package com.google.code.yanf4j.core.impl
Class FutureImpl<R>
- java.lang.Object
-
- com.google.code.yanf4j.core.impl.FutureImpl<R>
-
- All Implemented Interfaces:
java.util.concurrent.Future<R>
- Direct Known Subclasses:
ConnectFuture
public class FutureImpl<R> extends java.lang.Object implements java.util.concurrent.Future<R>
SimpleFuture
implementation, which uses synchronizationObject
to synchronize during the lifecycle.- See Also:
Future
-
-
Constructor Summary
Constructors Constructor Description FutureImpl()
FutureImpl(java.lang.Object sync)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
void
failure(java.lang.Throwable failure)
Notify about the failure, occured during asynchronous operation execution.R
get()
R
get(long timeout, java.util.concurrent.TimeUnit unit)
R
getResult()
Get current result value without any blocking.boolean
isCancelled()
boolean
isDone()
protected void
notifyHaveResult()
Notify blocked listeners threads about operation completion.void
setResult(R result)
Set the result value and notify about operation completion.
-
-
-
Field Detail
-
sync
private final java.lang.Object sync
-
isDone
private boolean isDone
-
isCancelled
private boolean isCancelled
-
failure
private java.lang.Throwable failure
-
result
protected R result
-
-
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)
- Specified by:
cancel
in interfacejava.util.concurrent.Future<R>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<R>
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<R>
-
get
public R get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
get
in interfacejava.util.concurrent.Future<R>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
get
public R get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
get
in interfacejava.util.concurrent.Future<R>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
failure
public void failure(java.lang.Throwable failure)
Notify about the failure, occured during asynchronous operation execution.- Parameters:
failure
-
-
notifyHaveResult
protected void notifyHaveResult()
Notify blocked listeners threads about operation completion.
-
-