Package com.illumon.iris.db.v2.select
Class SimulationClock
java.lang.Object
com.illumon.iris.db.v2.select.SimulationClock
- All Implemented Interfaces:
com.fishlib.base.clock.Clock
public class SimulationClock extends Object implements com.fishlib.base.clock.Clock
Clock implementation for use with ClockFilter implementations to advance simulation time.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description SimulationClock(DBDateTime startTime, DBDateTime endTime, long stepNanos)
Create a simulation clock for the specified time range and step.SimulationClock(String startTime, String endTime, String stepSize)
Create a simulation clock for the specified time range and step. -
Method Summary
Modifier and Type Method Description protected void
advance()
Advance the simulation.void
awaitDone()
Wait for the simulation to be done.void
awaitDoneUninterruptibly()
Wait for the simulation to be done, without ever throwing InterruptedException.DBDateTime
currentTime()
long
currentTimeMicros()
long
currentTimeMillis()
boolean
done()
Is the simulation done?protected DBDateTime
getEndTime()
protected long
getStepNanos()
protected void
setTime(DBDateTime time)
void
start()
Start the simulation.void
start(boolean maxSpeed)
Start the simulation.void
startForUnitTests()
-
Constructor Details
-
SimulationClock
public SimulationClock(@NotNull String startTime, @NotNull String endTime, @NotNull String stepSize)Create a simulation clock for the specified time range and step.- Parameters:
startTime
- The initial time that will be returned by this clock, before it is startedendTime
- The final time that will be returned by this clock, when the simulation has completedstepSize
- The time to "elapse" in each refresh loop
-
SimulationClock
Create a simulation clock for the specified time range and step.- Parameters:
startTime
- The initial time that will be returned by this clock, before it is startedendTime
- The final time that will be returned by this clock, when the simulation has completedstepNanos
- The number of nanoseconds to "elapse" in each refresh loop
-
-
Method Details
-
currentTimeMillis
public long currentTimeMillis()- Specified by:
currentTimeMillis
in interfacecom.fishlib.base.clock.Clock
-
currentTimeMicros
public long currentTimeMicros()- Specified by:
currentTimeMicros
in interfacecom.fishlib.base.clock.Clock
-
currentTime
-
start
public void start()Start the simulation. -
start
public void start(boolean maxSpeed)Start the simulation.- Parameters:
maxSpeed
- run the simulation clock at the max possible speed.
-
startForUnitTests
public void startForUnitTests() -
advance
protected void advance()Advance the simulation. Package access for unit tests. -
getEndTime
-
getStepNanos
protected long getStepNanos() -
setTime
-
done
public boolean done()Is the simulation done?- Returns:
- True if the simulation is done
-
awaitDoneUninterruptibly
public void awaitDoneUninterruptibly()Wait for the simulation to be done, without ever throwing InterruptedException. -
awaitDone
Wait for the simulation to be done.- Throws:
InterruptedException
-