public final class UnsafeFutureImpl<R> extends Object implements FutureImpl<R>
Future
implementation.Future
Modifier and Type | Field and Description |
---|---|
protected Set<CompletionHandler<R>> |
completionHandlers |
protected Throwable |
failure |
protected boolean |
isCancelled |
protected boolean |
isDone |
protected int |
recycleMark |
protected R |
result |
Modifier and Type | Method and Description |
---|---|
void |
addCompletionHandler(CompletionHandler<R> completionHandler)
Adds a
CompletionHandler , which will be notified once the
asynchronous computation, represented by this Future,
is complete. |
boolean |
cancel(boolean mayInterruptIfRunning) |
static <R> UnsafeFutureImpl<R> |
create()
Construct
Future . |
void |
failure(Throwable failure)
Notify about the failure, occured during asynchronous operation execution.
|
R |
get() |
R |
get(long timeout,
TimeUnit unit) |
R |
getResult()
Get current result value without any blocking.
|
boolean |
isCancelled() |
boolean |
isDone() |
void |
markForRecycle(boolean recycleResult)
Mark GrizzlyFuture as recyclable, so once result will come -
GrizzlyFuture object will be recycled and returned to a
thread local object pool.
|
protected void |
notifyHaveResult()
Notify blocked listeners threads about operation completion.
|
void |
recycle() |
void |
recycle(boolean recycleResult)
Recycle GrizzlyFuture now.
|
protected void |
reset() |
void |
result(R result)
Set the result value and notify about operation completion.
|
protected boolean isDone
protected boolean isCancelled
protected Throwable failure
protected Set<CompletionHandler<R>> completionHandlers
protected R result
protected int recycleMark
public static <R> UnsafeFutureImpl<R> create()
Future
.public void addCompletionHandler(CompletionHandler<R> completionHandler)
CompletionHandler
, which will be notified once the
asynchronous computation, represented by this Future,
is complete.addCompletionHandler
in interface GrizzlyFuture<R>
completionHandler
- CompletionHandler
public R getResult()
getResult
in interface FutureImpl<R>
public void result(R result)
result
in interface FutureImpl<R>
result
- the result valuepublic boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<R>
public R get() throws InterruptedException, ExecutionException
get
in interface Future<R>
InterruptedException
ExecutionException
public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<R>
InterruptedException
ExecutionException
TimeoutException
public void failure(Throwable failure)
failure
in interface FutureImpl<R>
failure
- protected void notifyHaveResult()
public void markForRecycle(boolean recycleResult)
GrizzlyFuture
markForRecycle
in interface GrizzlyFuture<R>
recycleResult
- if true - the GrizzlyFuture result,
if it support recyclable mechanism, will be also recycled together
with this GrizzlyFuture object.protected void reset()
public void recycle(boolean recycleResult)
GrizzlyFuture
recycle
in interface GrizzlyFuture<R>
recycleResult
- if true - the GrizzlyFuture result,
if it support recyclable mechanism, will be also recycled together
with this GrizzlyFuture object.Copyright © 2015 Oracle Corporation. All rights reserved.