java.lang.Object
org.glassfish.grizzly.utils.Futures
Set of
Future
utilities.- Author:
- Alexey Stashok
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R> GrizzlyFuture<R>
createReadyFuture
(Throwable error) Create aFuture
, which has a preset failure.static <R> GrizzlyFuture<R>
createReadyFuture
(R result) Create aFuture
, which has a preset result.static <R> FutureImpl<R>
Returns thread-safeFutureImpl
implementation.static <R> FutureImpl<R>
Returns non thread-safeFutureImpl
implementation.static <R> void
notifyCancel
(FutureImpl<R> future, CompletionHandler completionHandler) Complete passedFutureImpl
andCompletionHandler
via the cancellation notification.static <R> void
notifyFailure
(FutureImpl<R> future, CompletionHandler completionHandler, Throwable error) Complete passedFutureImpl
andCompletionHandler
using the passed errorstatic <R> void
notifyResult
(FutureImpl<R> future, CompletionHandler<R> completionHandler, R result) Complete passedFutureImpl
andCompletionHandler
using the passed result object.static <A,
B> CompletionHandler<B> toAdaptedCompletionHandler
(FutureImpl<A> future, CompletionHandler<A> completionHandler, GenericAdapter<B, A> adapter) static <A,
B> CompletionHandler<B> toAdaptedCompletionHandler
(FutureImpl<A> future, GenericAdapter<B, A> adapter) CreatesCompletionHandler
, which may serve as a bridge for passedFutureImpl
.static <R> CompletionHandler<R>
toCompletionHandler
(FutureImpl<R> future) CreatesCompletionHandler
, which may serve as a bridge for passedFutureImpl
.static <R> CompletionHandler<R>
toCompletionHandler
(FutureImpl<R> future, CompletionHandler<R> completionHandler) CreatesCompletionHandler
, which may serve as a bridge for passedFutureImpl
andCompletionHandler
objects.
-
Constructor Details
-
Futures
public Futures()
-
-
Method Details
-
createSafeFuture
Returns thread-safeFutureImpl
implementation. (Based on the JDKFutureTask
).- Returns:
- thread-safe
FutureImpl
implementation.
-
createUnsafeFuture
Returns non thread-safeFutureImpl
implementation.- Returns:
- non thread-safe
FutureImpl
implementation.
-
createReadyFuture
Create aFuture
, which has a preset result.- Parameters:
result
- the result- Returns:
- a
Future
, which has a preset result.
-
createReadyFuture
Create aFuture
, which has a preset failure.- Parameters:
error
- the failure- Returns:
- a
Future
, which has a preset failure.
-
notifyResult
public static <R> void notifyResult(FutureImpl<R> future, CompletionHandler<R> completionHandler, R result) Complete passedFutureImpl
andCompletionHandler
using the passed result object.- Parameters:
future
-FutureImpl
to be notifiedcompletionHandler
-CompletionHandler
to be notifiedresult
- the result
-
notifyFailure
public static <R> void notifyFailure(FutureImpl<R> future, CompletionHandler completionHandler, Throwable error) Complete passedFutureImpl
andCompletionHandler
using the passed error- Parameters:
future
-FutureImpl
to be notifiedcompletionHandler
-CompletionHandler
to be notifiederror
- the error.
-
notifyCancel
Complete passedFutureImpl
andCompletionHandler
via the cancellation notification.- Parameters:
future
-FutureImpl
to be notifiedcompletionHandler
-CompletionHandler
to be notified
-
toCompletionHandler
CreatesCompletionHandler
, which may serve as a bridge for passedFutureImpl
. All the notifications coming to the returnedCompletionHandler
will be passed to the passedFutureImpl
.- Returns:
CompletionHandler
, which may serve as a bridge for passedFutureImpl
. All the notifications coming to the returnedCompletionHandler
will be passed to the passedFutureImpl
.
-
toCompletionHandler
public static <R> CompletionHandler<R> toCompletionHandler(FutureImpl<R> future, CompletionHandler<R> completionHandler) CreatesCompletionHandler
, which may serve as a bridge for passedFutureImpl
andCompletionHandler
objects. All the notifications coming to the returnedCompletionHandler
will be passed to theFutureImpl
andCompletionHandler
passed as parameters.- Returns:
CompletionHandler
, which may serve as a bridge for passedFutureImpl
andCompletionHandler
objects. All the notifications coming to the returnedCompletionHandler
will be passed to theFutureImpl
andCompletionHandler
passed as parameters.
-
toAdaptedCompletionHandler
public static <A,B> CompletionHandler<B> toAdaptedCompletionHandler(FutureImpl<A> future, GenericAdapter<B, A> adapter) CreatesCompletionHandler
, which may serve as a bridge for passedFutureImpl
. All the notifications coming to the returnedCompletionHandler
will be adapted usingGenericAdapter
and passed to theFutureImpl
.- Returns:
CompletionHandler
, which may serve as a bridge for passedFutureImpl
. All the notifications coming to the returnedCompletionHandler
will be adapted usingGenericAdapter
and passed to theFutureImpl
.
-
toAdaptedCompletionHandler
public static <A,B> CompletionHandler<B> toAdaptedCompletionHandler(FutureImpl<A> future, CompletionHandler<A> completionHandler, GenericAdapter<B, A> adapter) CreatesCompletionHandler
, which may serve as a bridge for passedFutureImpl
andCompletionHandler
. All the notifications coming to the returnedCompletionHandler
will be adapted usingGenericAdapter
and passed to theFutureImpl
andCompletionHandler
.- Returns:
CompletionHandler
, which may serve as a bridge for passedFutureImpl
andCompletionHandler
. All the notifications coming to the returnedCompletionHandler
will be adapted usingGenericAdapter
and passed to theFutureImpl
andCompletionHandler
.
-