Class SimulationClock

java.lang.Object
io.deephaven.engine.table.impl.select.SimulationClock
All Implemented Interfaces:
Clock

public class SimulationClock extends Object implements Clock
Clock implementation for use with ClockFilter implementations to advance simulation time.
  • 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 started
      endTime - The final time that will be returned by this clock, when the simulation has completed
      stepSize - 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 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 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 interface Clock
      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 interface Clock
      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() and Clock.currentTimeMillis().

      Specified by:
      currentTimeNanos in interface Clock
      Returns:
      epoch nanoseconds
    • instantNanos

      public Instant 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(), prefer Clock.instantMillis().

      Specified by:
      instantNanos in interface Clock
      Returns:
      the instant
    • instantMillis

      public Instant instantMillis()
      Description copied from interface: Clock
      The instant.

      Has resolution greater than or equal to Clock.currentTimeMillis().

      Specified by:
      instantMillis in interface Clock
      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

      @VisibleForTesting public void 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

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