Class ActorControl
- All Implemented Interfaces:
ConcurrencyControl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCallables actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED<T> ActorFuture<T>Callables actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTEDclose()consume(ConsumableChannel channel, Runnable consumer) Consumers are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTEDstatic ActorControlcurrent()voiddone()voidfail()Mark actor as failed.booleanbooleanisClosed()booleanonCondition(String conditionName, Runnable conditionAction) Conditional actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTEDvoidRunnables submitted by the actor itself are executed while the actor is in any of its lifecycle phases.runAtFixedRate(Duration delay, Runnable runnable) Scheduled a repeating timerrunDelayed(Duration delay, Runnable runnable) The runnable is is executed while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED<T> voidrunOnCompletion(ActorFuture<T> future, BiConsumer<T, Throwable> callback) Invoke the callback when the given future is completed (successfully or exceptionally).<T> voidrunOnCompletion(Collection<ActorFuture<T>> futures, Consumer<Throwable> callback) Invoke the callback when the given futures are completed (successfully or exceptionally).<T> voidrunOnCompletionBlockingCurrentPhase(ActorFuture<T> future, BiConsumer<T, Throwable> callback) Invoke the callback when the given future is completed (successfully or exceptionally).voidrunUntilDone(Runnable runnable) Run the provided runnable repeatedly until it callsdone().voidsetPriority(ActorPriority priority) voidsetSchedulingHints(int hints) changes the actor's scheduling hints.voidLikerun(Runnable)but submits the runnable to the end end of the actor's queue such that other other actions may be executed before this.voidcan be called by the actor to yield the threadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.camunda.zeebe.util.sched.ConcurrencyControl
createCompletedFuture, createFuture
-
Constructor Details
-
ActorControl
-
-
Method Details
-
current
-
setSchedulingHints
public void setSchedulingHints(int hints) changes the actor's scheduling hints. For example, this makes it possible to transform a cpu-bound actor into an io-bound actor and vice versa.- Parameters:
hints- the changed scheduling hints
-
consume
Consumers are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Parameters:
channel-consumer-
-
onCondition
Conditional actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Parameters:
conditionName-conditionAction-- Returns:
-
call
Callables actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Parameters:
callable-- Returns:
-
call
Callables actions are called while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Parameters:
action-- Returns:
-
runUntilDone
Run the provided runnable repeatedly until it callsdone(). To be used for jobs which may experience backpressure. -
runDelayed
The runnable is is executed while the actor is in the following actor lifecycle phases:ActorTask.ActorLifecyclePhase.STARTED- Parameters:
delay-runnable-- Returns:
-
runAtFixedRate
Scheduled a repeating timerThe runnable is is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Parameters:
delay-runnable-- Returns:
-
runOnCompletion
Invoke the callback when the given future is completed (successfully or exceptionally). This call does not block the actor. If close is requested the actor will not wait on this future, in this case the callback is never called.The callback is is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Specified by:
runOnCompletionin interfaceConcurrencyControl- Type Parameters:
T- result type of the future- Parameters:
future- the future to wait oncallback- the callback that handle the future's result. The throwable isnullwhen the future is completed successfully.
-
run
Runnables submitted by the actor itself are executed while the actor is in any of its lifecycle phases.Runnables submitted externally are executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Specified by:
runin interfaceConcurrencyControl- Parameters:
action-
-
submit
Likerun(Runnable)but submits the runnable to the end end of the actor's queue such that other other actions may be executed before this. This method is useful in case an actor is in a (potentially endless) loop and it should be able to interrupt it.The runnable is is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Parameters:
action- the action to run.
-
runOnCompletionBlockingCurrentPhase
public <T> void runOnCompletionBlockingCurrentPhase(ActorFuture<T> future, BiConsumer<T, Throwable> callback) Invoke the callback when the given future is completed (successfully or exceptionally). This call does not block the actor. If close is requested the actor will wait on this future and not change the phase, in this case the callback will eventually called.The callback is is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Parameters:
future- the future to wait oncallback- the callback that handle the future's result. The throwable isnullwhen the future is completed successfully.
-
runOnCompletion
Invoke the callback when the given futures are completed (successfully or exceptionally). This call does not block the actor.The callback is is executed while the actor is in the following actor lifecycle phases:
ActorTask.ActorLifecyclePhase.STARTED- Parameters:
futures- the futures to wait oncallback- The throwable isnullwhen all futures are completed successfully. Otherwise, it holds the exception of the last completed future.
-
yieldThread
public void yieldThread()can be called by the actor to yield the thread -
close
-
done
public void done() -
isClosing
public boolean isClosing() -
isClosed
public boolean isClosed() -
setPriority
-
getLifecyclePhase
-
isCalledFromWithinActor
-
fail
public void fail()Mark actor as failed. This sets the lifecycle phase to 'FAILED' and discards all jobs.
-