Class ExecutionRun
java.lang.Object
com.soulfiremc.server.script.ExecutionRun
Per-invocation execution state.
Each trigger invocation gets its own ExecutionRun so that concurrent triggers
don't corrupt each other's node output sinks.
-
Constructor Summary
ConstructorsConstructorDescriptionExecutionRun(boolean tickSynchronous) ExecutionRun(boolean tickSynchronous, Duration dataEdgeTimeout, long maxExecutionCount, ScriptEventListener listener, reactor.core.scheduler.Scheduler reactorScheduler) -
Method Summary
Modifier and TypeMethodDescriptionawaitNodeOutputs(String nodeId, String nodeDesc) Waits for a node to produce outputs within this run.booleanGets and resets the check result flag.longReturns the current execution count for stats reporting.longReturns the maximum execution count limit.getPublishedOutputs(String nodeId) Returns the most recently published outputs for a node, or null if none published yet.booleanIncrements the execution count and checks if the limit has been exceeded.booleanReturns whether this execution is running synchronously on the tick thread.booleanmarkDataNodeTriggered(String nodeId) Marks a data-only node as triggered for eager execution within this run.voidPops the current check context from the stack.voidpublishNodeFailure(String nodeId) Publishes that a node has failed, allowing consumers waiting via awaitNodeOutputs to receive an empty result immediately instead of timing out.voidpublishNodeOutputs(String nodeId, Map<String, NodeValue> outputs) Publishes node outputs, allowing consumers to receive the latest value.voidPushes a new check context onto the stack for nested loop support.reactor.core.scheduler.SchedulerReturns the per-invocation Reactor scheduler.voidResets all data-only node trigger flags, allowing them to re-execute.voidsetCheckResult(boolean value) Sets the check result flag, used by ResultNode to communicate a boolean condition back to loop nodes (e.g., RepeatUntilNode).booleanReturns whether setCheckResult was called since the last reset.
-
Constructor Details
-
ExecutionRun
public ExecutionRun() -
ExecutionRun
public ExecutionRun(boolean tickSynchronous) -
ExecutionRun
public ExecutionRun(boolean tickSynchronous, Duration dataEdgeTimeout, long maxExecutionCount, ScriptEventListener listener, reactor.core.scheduler.Scheduler reactorScheduler)
-
-
Method Details
-
reactorScheduler
public reactor.core.scheduler.Scheduler reactorScheduler()Returns the per-invocation Reactor scheduler. -
isTickSynchronous
public boolean isTickSynchronous()Returns whether this execution is running synchronously on the tick thread. -
awaitNodeOutputs
public reactor.core.publisher.Mono<Map<String, NodeValue>> awaitNodeOutputs(String nodeId, String nodeDesc) Waits for a node to produce outputs within this run.- Parameters:
nodeId- the node to wait fornodeDesc- human-readable node descriptor for log messages- Returns:
- a Mono that completes with the node's outputs
-
publishNodeFailure
Publishes that a node has failed, allowing consumers waiting via awaitNodeOutputs to receive an empty result immediately instead of timing out.- Parameters:
nodeId- the failed node identifier
-
publishNodeOutputs
Publishes node outputs, allowing consumers to receive the latest value. Uses replay().latest() so that producers can emit multiple times (loops work) and consumers always get the most recent value.- Parameters:
nodeId- the node identifieroutputs- the output values
-
getPublishedOutputs
Returns the most recently published outputs for a node, or null if none published yet. Used for non-blocking synchronous resolution of on-path DATA edges.- Parameters:
nodeId- the node identifier- Returns:
- the published outputs, or null if not yet available
-
markDataNodeTriggered
Marks a data-only node as triggered for eager execution within this run. Returns true if this is the first time the node is marked (caller should execute it), false if already triggered (caller should skip, another path is handling it).- Parameters:
nodeId- the data-only node identifier- Returns:
- true if newly marked, false if already triggered
-
pushCheckContext
public void pushCheckContext()Pushes a new check context onto the stack for nested loop support. -
popCheckContext
public void popCheckContext()Pops the current check context from the stack. -
setCheckResult
public void setCheckResult(boolean value) Sets the check result flag, used by ResultNode to communicate a boolean condition back to loop nodes (e.g., RepeatUntilNode).- Parameters:
value- the boolean result
-
wasCheckResultSet
public boolean wasCheckResultSet()Returns whether setCheckResult was called since the last reset.- Returns:
- true if a ResultNode set the check result
-
getAndResetCheckResult
public boolean getAndResetCheckResult()Gets and resets the check result flag. Returns the current value and resets it to false.- Returns:
- the check result before reset
-
resetDataNodeTriggers
public void resetDataNodeTriggers()Resets all data-only node trigger flags, allowing them to re-execute. Used by loop nodes before evaluating check chains so that data-only nodes (e.g., CompareNode) can re-evaluate with fresh upstream values. -
incrementAndCheckLimit
public boolean incrementAndCheckLimit()Increments the execution count and checks if the limit has been exceeded.- Returns:
- true if execution is allowed, false if the limit has been exceeded
-
getExecutionCount
public long getExecutionCount()Returns the current execution count for stats reporting. -
getMaxExecutionCount
public long getMaxExecutionCount()Returns the maximum execution count limit.
-