Top Description Fields Constructors Methods
org.glassfish.grizzly.impl

public final Class ReadyFutureImpl<R>

extends Object
implements FutureImpl<R>
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.impl.FutureImpl, org.glassfish.grizzly.GrizzlyFuture, org.glassfish.grizzly.Cacheable, java.util.concurrent.Future
Imports
java.util.concurrent.CancellationException, .ExecutionException, .Future, .TimeUnit, .TimeoutException, org.glassfish.grizzly.Cacheable, .CompletionHandler, .ThreadCache

Future implementation with the specific unmodifiable result.
Author
Alexey Stashok
See Also
Future

Field Summary

Modifier and TypeField and Description
private static final ThreadCache.CachedTypeIndex<ReadyFutureImpl<R>>
private Throwable
private boolean
protected R

Constructor Summary

AccessConstructor and Description
private
ReadyFutureImpl()

Construct cancelled Future.

private
ReadyFutureImpl(R result)

Construct Future with the result.

private
ReadyFutureImpl(Throwable failure)

Construct failed Future.

private
ReadyFutureImpl(R result, Throwable failure, boolean isCancelled)

Method Summary

Modifier and TypeMethod and Description
public void
addCompletionHandler(final CompletionHandler<R> completionHandler)

Implements org.glassfish.grizzly.GrizzlyFuture.addCompletionHandler.

Adds a CompletionHandler, which will be notified once the asynchronous computation, represented by this Future, is complete.

public boolean

Returns:

cancel state, which was set during construction.
cancel
(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Do nothing.

public static <R> ReadyFutureImpl<R>
create()

Construct cancelled Future.

public static <R> ReadyFutureImpl<R>
create(R result)

Construct Future with the result.

public static <R> ReadyFutureImpl<R>
create(Throwable failure)

Construct failed Future.

public void
failure(Throwable failure)

Implements org.glassfish.grizzly.impl.FutureImpl.failure.

Should not be called for ReadyFutureImpl

public R
get()

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

public R
get(long timeout, TimeUnit unit)

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

public R

Returns:

current result value without any blocking.
getResult
()

Implements org.glassfish.grizzly.impl.FutureImpl.getResult.

Get current result value without any blocking.

public boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

public boolean
isDone()

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.

public void
markForRecycle(boolean recycleResult)

Implements org.glassfish.grizzly.GrizzlyFuture.markForRecycle.

Mark GrizzlyFuture as recyclable, so once result will come - GrizzlyFuture object will be recycled and returned to a thread local object pool.

public void
public void
recycle(boolean recycleResult)

Implements org.glassfish.grizzly.GrizzlyFuture.recycle.

Recycle GrizzlyFuture now.

private void
public void
result(R result)

Implements org.glassfish.grizzly.impl.FutureImpl.result.

Set the result value and notify about operation completion.

public void
setResult(R result)

Should not be called for ReadyFutureImpl

private static <R> ReadyFutureImpl<R>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CACHE_IDXback to summary
private static final ThreadCache.CachedTypeIndex<ReadyFutureImpl<R>> CACHE_IDX
failureback to summary
private Throwable failure
isCancelledback to summary
private boolean isCancelled
resultback to summary
protected R result

Constructor Detail

ReadyFutureImplback to summary
private ReadyFutureImpl()

Construct cancelled Future.

ReadyFutureImplback to summary
private ReadyFutureImpl(R result)

Construct Future with the result.

ReadyFutureImplback to summary
private ReadyFutureImpl(Throwable failure)

Construct failed Future.

ReadyFutureImplback to summary
private ReadyFutureImpl(R result, Throwable failure, boolean isCancelled)

Method Detail

addCompletionHandlerback to summary
public void addCompletionHandler(final CompletionHandler<R> completionHandler)

Implements org.glassfish.grizzly.GrizzlyFuture.addCompletionHandler.

Doc from org.glassfish.grizzly.GrizzlyFuture.addCompletionHandler.

Adds a CompletionHandler, which will be notified once the asynchronous computation, represented by this Future, is complete.

Annotations
@Override
cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Do nothing.

Returns:boolean

cancel state, which was set during construction.

Annotations
@Override
createback to summary
public static <R> ReadyFutureImpl<R> create()

Construct cancelled Future.

createback to summary
public static <R> ReadyFutureImpl<R> create(R result)

Construct Future with the result.

createback to summary
public static <R> ReadyFutureImpl<R> create(Throwable failure)

Construct failed Future.

failureback to summary
public void failure(Throwable failure)

Implements org.glassfish.grizzly.impl.FutureImpl.failure.

Should not be called for ReadyFutureImpl

Annotations
@Override
getback to summary
public R get() throws InterruptedException, ExecutionException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
getback to summary
public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
TimeoutException:
if the wait timed out
getResultback to summary
public R getResult()

Implements org.glassfish.grizzly.impl.FutureImpl.getResult.

Get current result value without any blocking.

Returns:R

current result value without any blocking.

Annotations
@Override
isCancelledback to summary
public boolean isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Annotations
@Override
isDoneback to summary
public boolean isDone()

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Annotations
@Override
markForRecycleback to summary
public void markForRecycle(boolean recycleResult)

Implements org.glassfish.grizzly.GrizzlyFuture.markForRecycle.

Doc from org.glassfish.grizzly.GrizzlyFuture.markForRecycle.

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.

Annotations
@Override
recycleback to summary
public void recycle()

Implements org.glassfish.grizzly.Cacheable.recycle.

Annotations
@Override
recycleback to summary
public void recycle(boolean recycleResult)

Implements org.glassfish.grizzly.GrizzlyFuture.recycle.

Doc from org.glassfish.grizzly.GrizzlyFuture.recycle.

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.

Annotations
@Override
resetback to summary
private void reset()
resultback to summary
public void result(R result)

Implements org.glassfish.grizzly.impl.FutureImpl.result.

Doc from org.glassfish.grizzly.impl.FutureImpl.result.

Set the result value and notify about operation completion.

Annotations
@Override
setResultback to summary
public void setResult(R result)

Should not be called for ReadyFutureImpl

takeFromCacheback to summary
private static <R> ReadyFutureImpl<R> takeFromCache()
Annotations
@SuppressWarnings:unchecked