org.glassfish.grizzly.impl
Class ReadyFutureImpl<R>

java.lang.Object
  extended by org.glassfish.grizzly.impl.ReadyFutureImpl<R>
All Implemented Interfaces:
java.util.concurrent.Future<R>, Cacheable, GrizzlyFuture<R>

public final class ReadyFutureImpl<R>
extends java.lang.Object
implements GrizzlyFuture<R>

Future implementation with the specific unmodifiable result.

Author:
Alexey Stashok
See Also:
Future

Field Summary
protected  R result
           
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
          Do nothing.
static
<R> ReadyFutureImpl<R>
create()
          Construct cancelled Future.
static
<R> ReadyFutureImpl<R>
create(R result)
          Construct Future with the result.
static
<R> ReadyFutureImpl<R>
create(java.lang.Throwable failure)
          Construct failed Future.
 void failure(java.lang.Throwable failure)
          Should not be called for ReadyFutureImpl
 R get()
          
 R get(long timeout, java.util.concurrent.TimeUnit unit)
          
 R getResult()
          Get current result value without any blocking.
 boolean isCancelled()
          
 boolean isDone()
          
 void markForRecycle(boolean recycleResult)
          Mark GrizzlyFuture as recycleable, 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 setResult(R result)
          Should not be called for ReadyFutureImpl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

result

protected R result
Method Detail

create

public static <R> ReadyFutureImpl<R> create()
Construct cancelled Future.


create

public static <R> ReadyFutureImpl<R> create(R result)
Construct Future with the result.


create

public static <R> ReadyFutureImpl<R> create(java.lang.Throwable failure)
Construct failed Future.


getResult

public R getResult()
Get current result value without any blocking.

Returns:
current result value without any blocking.

setResult

public void setResult(R result)
Should not be called for ReadyFutureImpl


cancel

public boolean cancel(boolean mayInterruptIfRunning)
Do nothing.

Specified by:
cancel in interface java.util.concurrent.Future<R>
Returns:
cancel state, which was set during construction.

isCancelled

public boolean isCancelled()

Specified by:
isCancelled in interface java.util.concurrent.Future<R>

isDone

public boolean isDone()

Specified by:
isDone in interface java.util.concurrent.Future<R>

get

public R get()
      throws java.lang.InterruptedException,
             java.util.concurrent.ExecutionException

Specified by:
get in interface java.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 interface java.util.concurrent.Future<R>
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException

failure

public void failure(java.lang.Throwable failure)
Should not be called for ReadyFutureImpl


markForRecycle

public void markForRecycle(boolean recycleResult)
Description copied from interface: GrizzlyFuture
Mark GrizzlyFuture as recycleable, 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 interface GrizzlyFuture<R>
Parameters:
recycleResult - if true - the GrizzlyFuture result, if it support recycleable mechanism, will be also recycled together with this GrizzlyFuture object.

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 interface GrizzlyFuture<R>
Parameters:
recycleResult - if true - the GrizzlyFuture result, if it support recycleable mechanism, will be also recycled together with this GrizzlyFuture object.

recycle

public void recycle()
Specified by:
recycle in interface Cacheable


Copyright © 2012 Oracle Corporation. All Rights Reserved.