public class QueueAsyncInvocationStage extends SimpleAsyncInvocationStage implements BiConsumer<Object,Throwable>, InvocationCallback
It stores handler objects in a queue instead of creating a new instance every time a handler is added.
The queue may be frozen based on internal conditions, like executing the last handler or reaching the capacity
of the queue, and adding a handler will create a new instance.
The queue will also be frozen when SimpleAsyncInvocationStage.toCompletableFuture()
is invoked, to make that future behave like
a regular CompletableFuture
.
When the queue is not frozen, adding a handler will change the result of the current stage. When the queue is frozen, adding a handler may actually execute the handler synchronously.
future
Constructor and Description |
---|
QueueAsyncInvocationStage(InvocationContext ctx,
VisitableCommand command,
CompletableFuture<?> valueFuture,
InvocationCallback function) |
Modifier and Type | Method and Description |
---|---|
void |
accept(Object rv,
Throwable throwable) |
Object |
addCallback(InvocationContext ctx,
VisitableCommand command,
InvocationCallback function)
After the current stage completes, invoke
function and return its result. |
Object |
apply(InvocationContext rCtx,
VisitableCommand rCommand,
Object rv,
Throwable throwable)
Process the result or the exception from an invocation stage and either return a simple value,
return a new
InvocationStage , or throw an exception. |
String |
toString() |
get, isDone, thenReturn, toCompletableFuture
andExceptionally, andExceptionallyMakeStage, andFinally, andFinallyMakeStage, andHandle, andHandleMakeStage, completedNullStage, makeStage, thenAccept, thenAcceptMakeStage, thenApply, thenApplyMakeStage
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
andThen
public QueueAsyncInvocationStage(InvocationContext ctx, VisitableCommand command, CompletableFuture<?> valueFuture, InvocationCallback function)
public Object addCallback(InvocationContext ctx, VisitableCommand command, InvocationCallback function)
InvocationStage
function
and return its result.
The result may be either a plain value, or a new InvocationStage
.
If function
throws an exception, the result InvocationStage
will complete with the same exception.
addCallback
in class SimpleAsyncInvocationStage
public void accept(Object rv, Throwable throwable)
accept
in interface BiConsumer<Object,Throwable>
public Object apply(InvocationContext rCtx, VisitableCommand rCommand, Object rv, Throwable throwable) throws Throwable
InvocationCallback
InvocationStage
, or throw an exception.apply
in interface InvocationCallback
Throwable
public String toString()
toString
in class SimpleAsyncInvocationStage
Copyright © 2021 JBoss by Red Hat. All rights reserved.