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.
  • 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 started
      endTime - The final time that will be returned by this clock, when the simulation has completed
      stepSize - The time to "elapse" in each refresh loop
    • SimulationClock

      public SimulationClock​(@NotNull DBDateTime startTime, @NotNull DBDateTime 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 started
      endTime - The final time that will be returned by this clock, when the simulation has completed
      stepNanos - The number of nanoseconds to "elapse" in each refresh loop
  • Method Details

    • currentTimeMillis

      public long currentTimeMillis()
      Specified by:
      currentTimeMillis in interface com.fishlib.base.clock.Clock
    • currentTimeMicros

      public long currentTimeMicros()
      Specified by:
      currentTimeMicros in interface com.fishlib.base.clock.Clock
    • currentTime

      public DBDateTime 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

      protected DBDateTime getEndTime()
    • getStepNanos

      protected long getStepNanos()
    • setTime

      protected void setTime​(DBDateTime time)
    • 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

      public void awaitDone() throws InterruptedException
      Wait for the simulation to be done.
      Throws:
      InterruptedException