java.lang.Object
org.glassfish.grizzly.impl.ReadyFutureImpl<R>
- All Implemented Interfaces:
Future<R>
,Cacheable
,GrizzlyFuture<R>
,FutureImpl<R>
Future
implementation with the specific unmodifiable result.- Author:
- Alexey Stashok
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCompletionHandler
(CompletionHandler<R> completionHandler) Adds aCompletionHandler
, which will be notified once the asynchronous computation, represented by this Future, is complete.boolean
cancel
(boolean mayInterruptIfRunning) Do nothing.static <R> ReadyFutureImpl<R>
create()
Construct cancelledFuture
.static <R> ReadyFutureImpl<R>
Construct failedFuture
.static <R> ReadyFutureImpl<R>
create
(R result) ConstructFuture
with the result.void
Should not be called for ReadyFutureImplget()
Get current result value without any blocking.boolean
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.void
recycle()
void
recycle
(boolean recycleResult) Recycle GrizzlyFuture now.void
Set the result value and notify about operation completion.void
Should not be called for ReadyFutureImpl
-
Field Details
-
result
-
-
Method Details
-
create
Construct cancelledFuture
. -
create
ConstructFuture
with the result. -
create
Construct failedFuture
. -
addCompletionHandler
Adds aCompletionHandler
, which will be notified once the asynchronous computation, represented by this Future, is complete.- Specified by:
addCompletionHandler
in interfaceGrizzlyFuture<R>
- Parameters:
completionHandler
-CompletionHandler
-
getResult
Get current result value without any blocking.- Specified by:
getResult
in interfaceFutureImpl<R>
- Returns:
- current result value without any blocking.
-
setResult
Should not be called for ReadyFutureImpl -
cancel
public boolean cancel(boolean mayInterruptIfRunning) Do nothing. -
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in interfaceFuture<R>
-
isDone
public boolean isDone() -
get
- Specified by:
get
in interfaceFuture<R>
- Throws:
InterruptedException
ExecutionException
-
get
public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
get
in interfaceFuture<R>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
failure
Should not be called for ReadyFutureImpl- Specified by:
failure
in interfaceFutureImpl<R>
-
result
Description copied from interface:FutureImpl
Set the result value and notify about operation completion.- Specified by:
result
in interfaceFutureImpl<R>
- Parameters:
result
- the result value
-
markForRecycle
public void markForRecycle(boolean recycleResult) Description copied from interface:GrizzlyFuture
Mark GrizzlyFuture as recyclable, so once result will come - GrizzlyFuture object will be recycled and returned to a thread local object pool. You can consider to use this method, if you're not interested in using this GrizzlyFuture object.- Specified by:
markForRecycle
in interfaceGrizzlyFuture<R>
- Parameters:
recycleResult
- if true - the GrizzlyFuture result, if it support recyclable mechanism, will be also recycled together with this GrizzlyFuture object.
-
recycle
public void recycle() -
recycle
public void recycle(boolean recycleResult) Description copied from interface:GrizzlyFuture
Recycle GrizzlyFuture now. This method could be used, if you're not interested in using this GrizzlyFuture object, and you're sure this object is not used by any other application part.- Specified by:
recycle
in interfaceGrizzlyFuture<R>
- Parameters:
recycleResult
- if true - the GrizzlyFuture result, if it support recyclable mechanism, will be also recycled together with this GrizzlyFuture object.
-