Class QueueAsyncInvocationStage
- All Implemented Interfaces:
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.
- Since:
- 9.0
- Author:
- Dan Berindei
-
Field Summary
Fields inherited from class org.infinispan.interceptors.impl.SimpleAsyncInvocationStage
future
-
Constructor Summary
ConstructorDescriptionQueueAsyncInvocationStage
(InvocationContext ctx, VisitableCommand command, CompletableFuture<?> valueFuture, InvocationCallback function) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCallback
(InvocationContext ctx, VisitableCommand command, InvocationCallback function) After the current stage completes, invokefunction
and return its result.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 newInvocationStage
, or throw an exception.toString()
Methods inherited from class org.infinispan.interceptors.impl.SimpleAsyncInvocationStage
get, isDone, thenReturn, toCompletableFuture
Methods inherited from class org.infinispan.interceptors.InvocationStage
andExceptionally, andExceptionallyMakeStage, andFinally, andFinallyMakeStage, andHandle, andHandleMakeStage, completedNullStage, makeStage, thenAccept, thenAcceptMakeStage, thenApply, thenApplyMakeStage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.function.BiConsumer
andThen
-
Constructor Details
-
QueueAsyncInvocationStage
public QueueAsyncInvocationStage(InvocationContext ctx, VisitableCommand command, CompletableFuture<?> valueFuture, InvocationCallback function)
-
-
Method Details
-
addCallback
public Object addCallback(InvocationContext ctx, VisitableCommand command, InvocationCallback function) Description copied from class:InvocationStage
After the current stage completes, invokefunction
and return its result.The result may be either a plain value, or a new
InvocationStage
. Iffunction
throws an exception, the resultInvocationStage
will complete with the same exception.- Overrides:
addCallback
in classSimpleAsyncInvocationStage
-
accept
- Specified by:
accept
in interfaceBiConsumer<Object,
Throwable>
-
apply
public Object apply(InvocationContext rCtx, VisitableCommand rCommand, Object rv, Throwable throwable) throws Throwable Description copied from interface:InvocationCallback
Process the result or the exception from an invocation stage and either return a simple value, return a newInvocationStage
, or throw an exception.- Specified by:
apply
in interfaceInvocationCallback
- Throws:
Throwable
-
toString
- Overrides:
toString
in classSimpleAsyncInvocationStage
-