Top Description Inners Constructors Methods
org.glassfish.grizzly.utils

public Class Futures

extends Object
Class Inheritance
Imports
java.util.concurrent.Future, org.glassfish.grizzly.CompletionHandler, .Copyable, .EmptyCompletionHandler, .GrizzlyFuture, org.glassfish.grizzly.impl.FutureImpl, .ReadyFutureImpl, .SafeFutureImpl, .UnsafeFutureImpl

Set of Future utilities.
Author
Alexey Stashok

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <R> GrizzlyFuture<R>

Returns:

a Future, which has a preset result.
createReadyFuture
(final R
the result
result
)

Create a Future, which has a preset result.

public static <R> GrizzlyFuture<R>

Returns:

a Future, which has a preset failure.
createReadyFuture
(final Throwable
the failure
error
)

Create a Future, which has a preset failure.

public static <R> FutureImpl<R>

Returns:

thread-safe FutureImpl implementation.
createSafeFuture
()

Returns thread-safe FutureImpl implementation.

public static <R> FutureImpl<R>

Returns:

non thread-safe FutureImpl implementation.
createUnsafeFuture
()

Returns non thread-safe FutureImpl implementation.

public static <R> void
notifyCancel(final FutureImpl<R>
FutureImpl to be notified
future
,
final CompletionHandler<E>
CompletionHandler to be notified
completionHandler
)

Complete passed FutureImpl and CompletionHandler via the cancellation notification.

public static <R> void
notifyFailure(final FutureImpl<R>
FutureImpl to be notified
future
,
final CompletionHandler<E>
CompletionHandler to be notified
completionHandler
,
final Throwable
the error.
error
)

Complete passed FutureImpl and CompletionHandler using the passed error

public static <R> void
notifyResult(final FutureImpl<R>
FutureImpl to be notified
future
,
final CompletionHandler<R>
CompletionHandler to be notified
completionHandler
,
final R
the result
result
)

Complete passed FutureImpl and CompletionHandler using the passed result object.

public static <A, B> CompletionHandler<B>

Returns:

CompletionHandler, which may serve as a bridge for passed FutureImpl. All the notifications coming to the returned CompletionHandler will be adapted using GenericAdapter and passed to the FutureImpl.
toAdaptedCompletionHandler
(final FutureImpl<A> future, final GenericAdapter<B, A> adapter)

Creates CompletionHandler, which may serve as a bridge for passed FutureImpl.

public static <A, B> CompletionHandler<B>

Returns:

CompletionHandler, which may serve as a bridge for passed FutureImpl and CompletionHandler. All the notifications coming to the returned CompletionHandler will be adapted using GenericAdapter and passed to the FutureImpl and CompletionHandler.
toAdaptedCompletionHandler
(final FutureImpl<A> future, final CompletionHandler<A> completionHandler, final GenericAdapter<B, A> adapter)

Creates CompletionHandler, which may serve as a bridge for passed FutureImpl and CompletionHandler.

public static <R> CompletionHandler<R>

Returns:

CompletionHandler, which may serve as a bridge for passed FutureImpl. All the notifications coming to the returned CompletionHandler will be passed to the passed FutureImpl.
toCompletionHandler
(final FutureImpl<R> future)

Creates CompletionHandler, which may serve as a bridge for passed FutureImpl.

public static <R> CompletionHandler<R>

Returns:

CompletionHandler, which may serve as a bridge for passed FutureImpl and CompletionHandler objects. All the notifications coming to the returned CompletionHandler will be passed to the FutureImpl and CompletionHandler passed as parameters.
toCompletionHandler
(final FutureImpl<R> future, final CompletionHandler<R> completionHandler)

Creates CompletionHandler, which may serve as a bridge for passed FutureImpl and CompletionHandler objects.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Futuresback to summary
public Futures()

Method Detail

createReadyFutureback to summary
public static <R> GrizzlyFuture<R> createReadyFuture(final R result)

Create a Future, which has a preset result.

Parameters
result:R

the result

Returns:GrizzlyFuture<R>

a Future, which has a preset result.

createReadyFutureback to summary
public static <R> GrizzlyFuture<R> createReadyFuture(final Throwable error)

Create a Future, which has a preset failure.

Parameters
error:Throwable

the failure

Returns:GrizzlyFuture<R>

a Future, which has a preset failure.

createSafeFutureback to summary
public static <R> FutureImpl<R> createSafeFuture()

Returns thread-safe FutureImpl implementation. (Based on the JDK java.util.concurrent.FutureTask).

Returns:FutureImpl<R>

thread-safe FutureImpl implementation.

createUnsafeFutureback to summary
public static <R> FutureImpl<R> createUnsafeFuture()

Returns non thread-safe FutureImpl implementation.

Returns:FutureImpl<R>

non thread-safe FutureImpl implementation.

notifyCancelback to summary
public static <R> void notifyCancel(final FutureImpl<R> future, final CompletionHandler<E> completionHandler)

Complete passed FutureImpl and CompletionHandler via the cancellation notification.

Parameters
future:FutureImpl<R>

FutureImpl to be notified

completionHandler:CompletionHandler<E>

CompletionHandler to be notified

notifyFailureback to summary
public static <R> void notifyFailure(final FutureImpl<R> future, final CompletionHandler<E> completionHandler, final Throwable error)

Complete passed FutureImpl and CompletionHandler using the passed error

Parameters
future:FutureImpl<R>

FutureImpl to be notified

completionHandler:CompletionHandler<E>

CompletionHandler to be notified

error:Throwable

the error.

notifyResultback to summary
public static <R> void notifyResult(final FutureImpl<R> future, final CompletionHandler<R> completionHandler, final R result)

Complete passed FutureImpl and CompletionHandler using the passed result object.

Parameters
future:FutureImpl<R>

FutureImpl to be notified

completionHandler:CompletionHandler<R>

CompletionHandler to be notified

result:R

the result

toAdaptedCompletionHandlerback to summary
public static <A, B> CompletionHandler<B> toAdaptedCompletionHandler(final FutureImpl<A> future, final GenericAdapter<B, A> adapter)

Creates CompletionHandler, which may serve as a bridge for passed FutureImpl. All the notifications coming to the returned CompletionHandler will be adapted using GenericAdapter and passed to the FutureImpl.

Returns:CompletionHandler<B>

CompletionHandler, which may serve as a bridge for passed FutureImpl. All the notifications coming to the returned CompletionHandler will be adapted using GenericAdapter and passed to the FutureImpl.

toAdaptedCompletionHandlerback to summary
public static <A, B> CompletionHandler<B> toAdaptedCompletionHandler(final FutureImpl<A> future, final CompletionHandler<A> completionHandler, final GenericAdapter<B, A> adapter)

Creates CompletionHandler, which may serve as a bridge for passed FutureImpl and CompletionHandler. All the notifications coming to the returned CompletionHandler will be adapted using GenericAdapter and passed to the FutureImpl and CompletionHandler.

Returns:CompletionHandler<B>

CompletionHandler, which may serve as a bridge for passed FutureImpl and CompletionHandler. All the notifications coming to the returned CompletionHandler will be adapted using GenericAdapter and passed to the FutureImpl and CompletionHandler.

toCompletionHandlerback to summary
public static <R> CompletionHandler<R> toCompletionHandler(final FutureImpl<R> future)

Creates CompletionHandler, which may serve as a bridge for passed FutureImpl. All the notifications coming to the returned CompletionHandler will be passed to the passed FutureImpl.

Returns:CompletionHandler<R>

CompletionHandler, which may serve as a bridge for passed FutureImpl. All the notifications coming to the returned CompletionHandler will be passed to the passed FutureImpl.

toCompletionHandlerback to summary
public static <R> CompletionHandler<R> toCompletionHandler(final FutureImpl<R> future, final CompletionHandler<R> completionHandler)

Creates CompletionHandler, which may serve as a bridge for passed FutureImpl and CompletionHandler objects. All the notifications coming to the returned CompletionHandler will be passed to the FutureImpl and CompletionHandler passed as parameters.

Returns:CompletionHandler<R>

CompletionHandler, which may serve as a bridge for passed FutureImpl and CompletionHandler objects. All the notifications coming to the returned CompletionHandler will be passed to the FutureImpl and CompletionHandler passed as parameters.

org.glassfish.grizzly.utils back to summary

private final Class Futures.FutureToCompletionHandler<E>

extends EmptyCompletionHandler<E>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final FutureImpl<E>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
Inherited from org.glassfish.grizzly.EmptyCompletionHandler:
updated

Field Detail

futureback to summary
private final FutureImpl<E> future

Constructor Detail

FutureToCompletionHandlerback to summary
public FutureToCompletionHandler(FutureImpl<E> future)

Method Detail

cancelledback to summary
public void cancelled()

Overrides org.glassfish.grizzly.EmptyCompletionHandler.cancelled.

Implements org.glassfish.grizzly.CompletionHandler.cancelled.

Doc from org.glassfish.grizzly.EmptyCompletionHandler.cancelled.

The operation was cancelled.

Annotations
@Override
completedback to summary
public void completed(E result)

Overrides org.glassfish.grizzly.EmptyCompletionHandler.completed.

Implements org.glassfish.grizzly.CompletionHandler.completed.

Doc from org.glassfish.grizzly.EmptyCompletionHandler.completed.

The operation was completed.

Annotations
@Override
@SuppressWarnings:unchecked
failedback to summary
public void failed(final Throwable throwable)

Overrides org.glassfish.grizzly.EmptyCompletionHandler.failed.

Implements org.glassfish.grizzly.CompletionHandler.failed.

Doc from org.glassfish.grizzly.EmptyCompletionHandler.failed.

The operation was failed.

Annotations
@Override