Interface Job
public interface Job
A multi-tick piece of work a task node drives by calling
step(privbot.task.PrivTaskContext) once per pass until it is finished.
Thread rule: call step from the task thread that owns the PrivTaskContext; an implementation
waits only through ctx.sleepUntil and never blocks on its own. state() and reason() are
plain reads of what the last step decided and are safe from any thread.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidcancel()Stops the job: it ends FAILED with reason "cancelled", stops any background work it started (a route, a sub-job, a worker), and a laterstep(privbot.task.PrivTaskContext)never clicks.reason()Why the job is not RUNNING (what failed or why it is unsupported); "" while RUNNING.state()The state after the latest step; RUNNING before the first.step(PrivTaskContext ctx) Advance the job one step and return the state it ended in.
-
Method Details
-
step
Advance the job one step and return the state it ended in. -
state
JobState state()The state after the latest step; RUNNING before the first. -
cancel
default void cancel()Stops the job: it ends FAILED with reason "cancelled", stops any background work it started (a route, a sub-job, a worker), and a laterstep(privbot.task.PrivTaskContext)never clicks. Safe to call twice and on a finished job (which keeps its own state).Thread rule: this may be called from another thread (the plugin's Stop) while
step(privbot.task.PrivTaskContext)is running on the script worker. Implementations must tolerate that concurrent step: the first terminal state wins, and an in-flight step that started something after the cancel landed cancels it again before returning. Every public job (ctx.loot,ctx.restock,ctx.loadouts.equip,ctx.travel.go,ctx.recovery.afterDeath) overrides this. -
reason
String reason()Why the job is not RUNNING (what failed or why it is unsupported); "" while RUNNING.
-