public class SafeFutureImpl<R> extends Object implements FutureImpl<R>
FutureImpl
implementation.
(Based on the JDK FutureTask
)Future
Constructor and Description |
---|
SafeFutureImpl()
Creates SafeFutureImpl
|
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> SafeFutureImpl<R> |
create()
Construct
SafeFutureImpl . |
protected void |
done()
Protected method invoked when this task transitions to state
isDone (whether normally or via cancellation).
|
void |
failure(Throwable failure)
Notify about the failure, occurred 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 |
onComplete()
The method is called when this SafeFutureImpl is marked as completed.
|
void |
recycle() |
void |
recycle(boolean recycleResult)
Recycle GrizzlyFuture now.
|
void |
result(R result)
Set the result value and notify about operation completion.
|
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 static <R> SafeFutureImpl<R> create()
SafeFutureImpl
.public void result(R result)
result
in interface FutureImpl<R>
result
- the result valuepublic void failure(Throwable failure)
failure
in interface FutureImpl<R>
failure
- 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.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.public R getResult()
FutureImpl
getResult
in interface FutureImpl<R>
protected void onComplete()
public boolean isCancelled()
isCancelled
in interface Future<R>
public boolean cancel(boolean mayInterruptIfRunning)
public R get() throws InterruptedException, ExecutionException
get
in interface Future<R>
CancellationException
InterruptedException
ExecutionException
public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<R>
CancellationException
InterruptedException
ExecutionException
TimeoutException
protected void done()
Copyright © 2015 Oracle Corporation. All rights reserved.