Interface Promise.Invocable<R>
- Type Parameters:
R
- The result type
- All Known Subinterfaces:
Blocker.Promise<C>
- All Known Implementing Classes:
Promise.Invocable.Abstract
,Promise.Invocable.NonBlocking
An
Invocable
Promise
that provides
the Invocable.InvocationType
of calls to Promise.succeeded(Object)
.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Abstract implementation ofPromise.Invocable
with the specifiedInvocable.InvocationType
.static class
Abstract implementation ofPromise.Invocable
withInvocable.InvocationType
set toInvocable.InvocationType.NON_BLOCKING
.Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Promise
Promise.Completable<S>, Promise.Invocable<R>, Promise.Task<T>, Promise.Wrapper<W>
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T> Promise.Invocable
<T> from
(Runnable beforeComplete, Promise.Invocable<T> promise) Returns a promise that, when it is completed, runs the givenRunnable
and then completes the given promise.static <T> Promise.Invocable
<T> from
(Promise.Invocable<T> promise, Runnable afterComplete) Returns a promise that, when it is completed, completes the given promise and then runs the givenRunnable
.static <T> Promise.Invocable
<T> from
(Invocable.InvocationType invocationType, BiConsumer<T, Throwable> consumer) Factory method to create a promise from the given arguments.static <T> Promise.Invocable
<T> from
(Invocable.InvocationType invocationType, Consumer<T> success, Consumer<Throwable> failure) Factory method to create a promise from the given arguments.static <T> Promise.Invocable
<T> noop()
static <R> BiConsumer
<R, Throwable> toBiConsumer
(Promise.Invocable<R> promise) Returns aBiConsumer
that, when it is invoked, completes the given promisestatic <T> Callback
toCallback
(Promise.Invocable<T> promise, T result) Returns a newCallback
that, when it is completed, completes the given promise.static <W> Promise.Invocable
<W> toPromise
(CompletableFuture<W> completable) Returns a new promise that, when it is completed, completes the givenCompletableFuture
.static <W,
T> Promise.Invocable <W> toPromise
(Promise.Invocable<T> promise, Function<W, T> mapper) Returns a new promise that, when it is completed, completes the given promise.Methods inherited from interface org.eclipse.jetty.util.thread.Invocable
getInvocationType
-
Method Details
-
noop
- Type Parameters:
T
- the type of the promise result- Returns:
- a promise that performs no operations.
-
toCallback
Returns a new
Callback
that, when it is completed, completes the given promise. -
toPromise
Returns a new promise that, when it is completed, completes the given promise.
- Type Parameters:
W
- the wrapper typeT
- the promise type- Parameters:
promise
- the promise to wrapmapper
- a function that converts the result type- Returns:
- a new promise wrapping the given promise
-
toPromise
Returns a new promise that, when it is completed, completes the given
CompletableFuture
.- Type Parameters:
W
- the result type- Parameters:
completable
- theCompletableFuture
to complete- Returns:
- a new promise
-
toBiConsumer
Returns a
BiConsumer
that, when it is invoked, completes the given promiseTypical usage is with
CompletableFuture.whenComplete(BiConsumer)
:void example(Promise<T> promise) { CompletableFuture<T> completable = ...; completable.whenComplete(Promise.Invocable.toBiConsumer(promise)); }
- Parameters:
promise
- the promise to wrap
-
from
static <T> Promise.Invocable<T> from(Invocable.InvocationType invocationType, Consumer<T> success, Consumer<Throwable> failure) Factory method to create a promise from the given arguments.
- Type Parameters:
T
- the type of the promise result- Parameters:
invocationType
- theInvocable.InvocationType
of the promisesuccess
- the consumer to run upon successfailure
- the consumer to run upon failure- Returns:
- a new promise
-
from
static <T> Promise.Invocable<T> from(Invocable.InvocationType invocationType, BiConsumer<T, Throwable> consumer) Factory method to create a promise from the given arguments.
- Type Parameters:
T
- the type of the promise result- Parameters:
invocationType
- theInvocable.InvocationType
of the promiseconsumer
- the consumer to run upon completion- Returns:
- a new promise
-
from
Returns a promise that, when it is completed, completes the given promise and then runs the given
Runnable
.- Type Parameters:
T
- the type of the promise result- Parameters:
promise
- the promise to wrapafterComplete
- theRunnable
to run after completion- Returns:
- a new promise wrapping the given promise
- See Also:
-
from
Returns a promise that, when it is completed, runs the given
Runnable
and then completes the given promise.- Type Parameters:
T
- the type of the promise result- Parameters:
beforeComplete
- theRunnable
to run before completionpromise
- the promise to wrap- Returns:
- a new promise wrapping the given promise
- See Also:
-