Class LogicalClockImpl

java.lang.Object
io.deephaven.engine.updategraph.LogicalClockImpl
All Implemented Interfaces:
LogicalClock

public class LogicalClockImpl extends Object implements LogicalClock

A logical update clock that has two states, Updating and Idle.

Each time startUpdateCycle() is called, the clock transitions to the Updating state and the current value is incremented by one.

When completeUpdateCycle() is called, the clock transitions back to Idle.

  • Constructor Details

    • LogicalClockImpl

      public LogicalClockImpl()
  • Method Details

    • currentValue

      public final long currentValue()
      Get the current value of the clock.
      Specified by:
      currentValue in interface LogicalClock
    • startUpdateCycle

      public final long startUpdateCycle()
      Increment the current value and set the clock state to updating.
      ImplNote:
      The clock must have been idle before this method is called.
    • completeUpdateCycle

      public final void completeUpdateCycle()
      Increment the current step and set the clock state to idle.
      ImplNote:
      The clock must have been updating before this method is called.
    • ensureUpdateCycleCompleted

      public final void ensureUpdateCycleCompleted(long updatingCycleValue)
      After we complete a table run, we must ensure that the logical clock is idle.

      The only valid possibilities are (1) we have completed the cycle, in which case we return; or (2) we have terminated the cycle early and have the same value as at the start of our updating cycle, in which case we complete the cycle.

      If our clock is any other value; then it was changed out from under us and we throw an exception.

      Parameters:
      updatingCycleValue - the clock value at the end of startUpdateCycle()
    • resetForUnitTests

      @TestUseOnly public final void resetForUnitTests()
      Reset the clock to its initial state, in order to ensure that unit tests proceed cleanly.