Package io.deephaven.engine.updategraph
Class LogicalClockImpl
java.lang.Object
io.deephaven.engine.updategraph.LogicalClockImpl
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.engine.updategraph.LogicalClock
LogicalClock.State
-
Field Summary
Fields inherited from interface io.deephaven.engine.updategraph.LogicalClock
NULL_CLOCK_VALUE, STATE_MASK, STEP_SHIFT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Increment the current step and set the clock state toidle
.final long
Get the current value of the clock.final void
ensureUpdateCycleCompleted
(long updatingCycleValue) After we complete a table run, we must ensure that the logical clock is idle.final void
Reset the clock to its initial state, in order to ensure that unit tests proceed cleanly.final long
Increment the current value and set the clock state toupdating
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.deephaven.engine.updategraph.LogicalClock
currentState, currentStep
-
Constructor Details
-
LogicalClockImpl
public LogicalClockImpl()
-
-
Method Details
-
currentValue
public final long currentValue()Get the current value of the clock.- Specified by:
currentValue
in interfaceLogicalClock
-
startUpdateCycle
public final long startUpdateCycle()Increment the current value and set the clock state toupdating
.- 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 toidle
.- 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 ofstartUpdateCycle()
-
resetForUnitTests
Reset the clock to its initial state, in order to ensure that unit tests proceed cleanly.
-