Class StagedTaskRunner<C>
java.lang.Object
privbot.task.StagedTaskRunner<C>
- Type Parameters:
C- context type
Runs
TaskNodes in AutomationStage order. Each tick, the first
stage (in enum declaration order) that has at least one valid node executes
exactly one node — the highest-priority valid node within that stage.
Later stages are skipped once a node runs. If no node runs in any stage, the
tick is idle (same as TaskNodeRunner when nothing validates).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStagedTaskRunner(Supplier<C> contextSupplier) StagedTaskRunner(Supplier<C> contextSupplier, BooleanSupplier runnableCheck) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNode(AutomationStage stage, TaskNode<C> node) Registers a node for a stage.voidRemoves every registered node.booleanThe last executed node's return value; false on an idle tick.The node that ran on the last tick, or null when that tick was idle.The name of the node that ran on the last tick, or null when idle.That node's status after it ran, or"Idle".Node name to how many times it executed (unmodifiable view).Node name to its last execution time in milliseconds (unmodifiable view).The stage ofgetActiveNode(), or null when the last tick was idle.intThe number of registered nodes across all stages.getNodes()An unmodifiable snapshot of all nodes, in stage order then registration order.A multi-line report of every node with its stage, priority and execution statistics.longTicks processed sinceinitialize(), idle ticks included.voidClears active state and execution statistics.voidremoveNode(String name) Removes every node with this name, from every stage.voidreset()Resets every node and clears active state; statistics are kept.voidshutdown()CallsTaskNode.cleanup()on every node.booleantick()Runs one tick: the highest-priority valid node of the first stage that has one executes.
-
Constructor Details
-
StagedTaskRunner
-
StagedTaskRunner
- Parameters:
contextSupplier- supplies the shared context each tickrunnableCheck- when it returns false,tick()does nothing
-
-
Method Details
-
addNode
Registers a node for a stage. Nodes in the same stage compete byTaskNode.getPriority()(higher wins). -
removeNode
Removes every node with this name, from every stage. -
getNodes
-
getActiveNode
-
getLastActiveStage
The stage ofgetActiveNode(), or null when the last tick was idle. -
getNodeCount
public int getNodeCount()The number of registered nodes across all stages. -
initialize
public void initialize()Clears active state and execution statistics. Does not reset nodes. -
shutdown
public void shutdown()CallsTaskNode.cleanup()on every node. UnlikeTaskNodeRunner.shutdown()there is no worker to stop, and a node whose cleanup throws stops the loop. -
tick
public boolean tick()Runs one tick: the highest-priority valid node of the first stage that has one executes.Threading: selection and execution both run on the calling thread, with no
ReadScopeand no forced-move hold check. Call it from a script worker if nodes sleep, and make sure their predicates may read from that thread.- Returns:
- true if the selected node performed a blocking action
-
getActiveTaskName
The name of the node that ran on the last tick, or null when idle. -
getActiveTaskStatus
That node's status after it ran, or"Idle". -
didLastTickBlock
public boolean didLastTickBlock()The last executed node's return value; false on an idle tick. -
getExecutionTimes
-
getExecutionCounts
-
getTotalTicks
public long getTotalTicks()Ticks processed sinceinitialize(), idle ticks included. -
getNodeStats
A multi-line report of every node with its stage, priority and execution statistics. -
reset
public void reset()Resets every node and clears active state; statistics are kept. -
clearNodes
public void clearNodes()Removes every registered node.
-