Class Clock
java.lang.Object
com.assemblyrobot.simulator.core.clock.Clock
public class Clock
extends java.lang.Object
Centralised, monotonic simulator clock with support for attaching listeners to monitor clock
advancements.
-
Constructor Summary
Constructors Constructor Description Clock() -
Method Summary
Modifier and Type Method Description voidadvanceTick(long amount)Move the clock forward by a set number of ticks.voidnextTick()Move the clock forward by one tick.voidregisterTickAdvanceListener(@NonNull TickAdvanceListener listener)Register a tick advancement listener.voidreset()Reset the clock tick to 0.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Clock
public Clock()
-
-
Method Details
-
nextTick
public void nextTick()Move the clock forward by one tick. -
advanceTick
public void advanceTick(long amount) throws java.lang.IllegalArgumentExceptionMove the clock forward by a set number of ticks.- Parameters:
amount- Amount to move the clock forward by.- Throws:
java.lang.IllegalArgumentException- If the provided tick advancement is less than 0.
-
reset
public void reset()Reset the clock tick to 0. -
registerTickAdvanceListener
Register a tick advancement listener.- Parameters:
listener-TickAdvanceListener
-