Class WorldScheduler
java.lang.Object
io.github.protasm.jvmud.engine.time.WorldScheduler
Owns deterministic world time and scheduled work for one JVMud world.
The scheduler does not run on a background thread. Callers explicitly advance world time, which makes tests, admin tooling, and future persistence checkpoints repeatable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadvanceBy(long ticks) Advances world time by the supplied non-negative number of ticks.voidadvanceTo(long targetTick) Advances world time to an absolute target tick and runs all due work in deterministic order.longReturns the current deterministic world tick.scheduleAfter(long delayTicks, Runnable action) Schedules one action after a non-negative number of ticks.scheduleRecurring(long initialDelayTicks, long intervalTicks, Runnable action) Schedules a recurring action.
-
Constructor Details
-
WorldScheduler
public WorldScheduler()
-
-
Method Details
-
currentTick
public long currentTick()Returns the current deterministic world tick. -
scheduleAfter
Schedules one action after a non-negative number of ticks.- Returns:
- a handle that can cancel the scheduled action before it runs
-
scheduleRecurring
Schedules a recurring action.- Parameters:
initialDelayTicks- non-negative delay before the first runintervalTicks- positive interval between later runs- Returns:
- a handle that can cancel future occurrences
-
advanceBy
public void advanceBy(long ticks) Advances world time by the supplied non-negative number of ticks. -
advanceTo
public void advanceTo(long targetTick) Advances world time to an absolute target tick and runs all due work in deterministic order.- Throws:
IllegalArgumentException- if the target would move time backward
-