Class SimulationClock
java.lang.Object
io.deephaven.engine.table.impl.select.SimulationClock
- All Implemented Interfaces:
Clock
Clock implementation for use with ClockFilter implementations to advance simulation time.
-
Constructor Summary
ConstructorDescriptionSimulationClock
(@NotNull String startTime, @NotNull String endTime, @NotNull String stepSize) Create a simulation clock for the specified time range and step.SimulationClock
(@NotNull Instant startTime, @NotNull Instant endTime, long stepNanos) Create a simulation clock for the specified time range and step. -
Method Summary
Modifier and TypeMethodDescriptionvoid
advance()
Advance the simulation.void
Wait for the simulation to be done.void
Wait for the simulation to be done, without ever throwing InterruptedException.long
Microseconds since the epoch, 1970-01-01T00:00:00Z.long
Milliseconds since the epoch, 1970-01-01T00:00:00Z.long
Nanoseconds since the epoch, 1970-01-01T00:00:00Z.boolean
done()
Is the simulation done?The instant.The instant.void
start()
Start the simulation.void
start
(boolean maxSpeed) Start the simulation.
-
Constructor Details
-
SimulationClock
public SimulationClock(@NotNull @NotNull String startTime, @NotNull @NotNull String endTime, @NotNull @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 run loop
-
SimulationClock
public SimulationClock(@NotNull @NotNull Instant startTime, @NotNull @NotNull Instant endTime, long stepNanos) 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 run loop
-
-
Method Details
-
currentTimeMillis
public long currentTimeMillis()Description copied from interface:Clock
Milliseconds since the epoch, 1970-01-01T00:00:00Z.The resolution is dependent on the JVM and underlying implementation.
- Specified by:
currentTimeMillis
in interfaceClock
- Returns:
- epoch millis
-
currentTimeMicros
public long currentTimeMicros()Description copied from interface:Clock
Microseconds since the epoch, 1970-01-01T00:00:00Z.The resolution is dependent on the JVM and underlying implementation. The resolution is greater than or equal to
Clock.currentTimeMillis()
.- Specified by:
currentTimeMicros
in interfaceClock
- Returns:
- epoch microseconds
-
currentTimeNanos
public long currentTimeNanos()Description copied from interface:Clock
Nanoseconds since the epoch, 1970-01-01T00:00:00Z.The resolution is dependent on the JVM and underlying implementation. The resolution is greater than or equal to
Clock.currentTimeMicros()
andClock.currentTimeMillis()
.- Specified by:
currentTimeNanos
in interfaceClock
- Returns:
- epoch nanoseconds
-
instantNanos
Description copied from interface:Clock
The instant.Has resolution equal to
Clock.currentTimeNanos()
.If you don't need the resolution provided by
Clock.currentTimeNanos()
, preferClock.instantMillis()
.- Specified by:
instantNanos
in interfaceClock
- Returns:
- the instant
-
instantMillis
Description copied from interface:Clock
The instant.Has resolution greater than or equal to
Clock.currentTimeMillis()
.- Specified by:
instantMillis
in interfaceClock
- Returns:
- the instant.
-
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.
-
advance
Advance the simulation. Public access for unit tests. -
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
-