java.lang.Object
org.glassfish.grizzly.utils.Futures
Set of
Future utilities.- Author:
- Alexey Stashok
-
Constructor Summary
Constructors -
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-safeFutureImplimplementation.static <R> FutureImpl<R>Returns non thread-safeFutureImplimplementation.static <R> voidnotifyCancel(FutureImpl<R> future, CompletionHandler completionHandler) Complete passedFutureImplandCompletionHandlervia the cancellation notification.static <R> voidnotifyFailure(FutureImpl<R> future, CompletionHandler completionHandler, Throwable error) Complete passedFutureImplandCompletionHandlerusing the passed errorstatic <R> voidnotifyResult(FutureImpl<R> future, CompletionHandler<R> completionHandler, R result) Complete passedFutureImplandCompletionHandlerusing 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 passedFutureImplandCompletionHandlerobjects.
-
Constructor Details
-
Futures
public Futures()
-
-
Method Details
-
createSafeFuture
Returns thread-safeFutureImplimplementation. (Based on the JDKFutureTask).- Returns:
- thread-safe
FutureImplimplementation.
-
createUnsafeFuture
Returns non thread-safeFutureImplimplementation.- Returns:
- non thread-safe
FutureImplimplementation.
-
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 passedFutureImplandCompletionHandlerusing the passed result object.- Parameters:
future-FutureImplto be notifiedcompletionHandler-CompletionHandlerto be notifiedresult- the result
-
notifyFailure
public static <R> void notifyFailure(FutureImpl<R> future, CompletionHandler completionHandler, Throwable error) Complete passedFutureImplandCompletionHandlerusing the passed error- Parameters:
future-FutureImplto be notifiedcompletionHandler-CompletionHandlerto be notifiederror- the error.
-
notifyCancel
Complete passedFutureImplandCompletionHandlervia the cancellation notification.- Parameters:
future-FutureImplto be notifiedcompletionHandler-CompletionHandlerto be notified
-
toCompletionHandler
CreatesCompletionHandler, which may serve as a bridge for passedFutureImpl. All the notifications coming to the returnedCompletionHandlerwill be passed to the passedFutureImpl.- Returns:
CompletionHandler, which may serve as a bridge for passedFutureImpl. All the notifications coming to the returnedCompletionHandlerwill 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 passedFutureImplandCompletionHandlerobjects. All the notifications coming to the returnedCompletionHandlerwill be passed to theFutureImplandCompletionHandlerpassed as parameters.- Returns:
CompletionHandler, which may serve as a bridge for passedFutureImplandCompletionHandlerobjects. All the notifications coming to the returnedCompletionHandlerwill be passed to theFutureImplandCompletionHandlerpassed 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 returnedCompletionHandlerwill be adapted usingGenericAdapterand passed to theFutureImpl.- Returns:
CompletionHandler, which may serve as a bridge for passedFutureImpl. All the notifications coming to the returnedCompletionHandlerwill be adapted usingGenericAdapterand 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 passedFutureImplandCompletionHandler. All the notifications coming to the returnedCompletionHandlerwill be adapted usingGenericAdapterand passed to theFutureImplandCompletionHandler.- Returns:
CompletionHandler, which may serve as a bridge for passedFutureImplandCompletionHandler. All the notifications coming to the returnedCompletionHandlerwill be adapted usingGenericAdapterand passed to theFutureImplandCompletionHandler.
-