Package org.eclipse.jetty.util
Interface Callback
-
- All Superinterfaces:
Invocable
- All Known Implementing Classes:
Callback.Completable,Callback.Nested,CompletableCallback,CountingCallback,FutureCallback,IteratingCallback,IteratingNestedCallback,SharedBlockingCallback.Blocker
public interface Callback extends Invocable
A callback abstraction that handles completed/failed events of asynchronous operations.
Semantically this is equivalent to an optimise Promise<Void>, but callback is a more meaningful name than EmptyPromise
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classCallback.CompletableA CompletableFuture that is also a Callback.static classCallback.Nested-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.InvocationType
-
-
Field Summary
Fields Modifier and Type Field Description static CallbackNOOPInstance of Adapter that can be used when the callback methods need an empty implementation without incurring in the cost of allocating a new Adapter object.-
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default voidfailed(Throwable x)Callback invoked when the operation fails.static Callbackfrom(CompletableFuture<?> completable)Creates a non-blocking callback from the given incomplete CompletableFuture.static Callbackfrom(CompletableFuture<?> completable, Invocable.InvocationType invocation)Creates a callback from the given incomplete CompletableFuture, with the givenblockingcharacteristic.default voidsucceeded()Callback invoked when the operation completes.-
Methods inherited from interface org.eclipse.jetty.util.thread.Invocable
getInvocationType
-
-
-
-
Field Detail
-
NOOP
static final Callback NOOP
Instance of Adapter that can be used when the callback methods need an empty implementation without incurring in the cost of allocating a new Adapter object.
-
-
Method Detail
-
succeeded
default void succeeded()
Callback invoked when the operation completes.
- See Also:
failed(Throwable)
-
failed
default void failed(Throwable x)
Callback invoked when the operation fails.
- Parameters:
x- the reason for the operation failure
-
from
static Callback from(CompletableFuture<?> completable)
Creates a non-blocking callback from the given incomplete CompletableFuture.
When the callback completes, either succeeding or failing, the CompletableFuture is also completed, respectively via
CompletableFuture.complete(Object)orCompletableFuture.completeExceptionally(Throwable).- Parameters:
completable- the CompletableFuture to convert into a callback- Returns:
- a callback that when completed, completes the given CompletableFuture
-
from
static Callback from(CompletableFuture<?> completable, Invocable.InvocationType invocation)
Creates a callback from the given incomplete CompletableFuture, with the given
blockingcharacteristic.- Parameters:
completable- the CompletableFuture to convert into a callbackinvocation- whether the callback is blocking- Returns:
- a callback that when completed, completes the given CompletableFuture
-
-