Skip to content

Commit

Permalink
[SDCISA-15833] Fix broken timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddenalpha committed May 2, 2024
1 parent 35cac5d commit 68a2a77
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public Worker() {
long timeUpToNextPeriodMs = previousTriggerEpochMs + MEASURE_ALL_N_MILLIS - nowMs;
// skip a beat if we're too far behind.
while (timeUpToNextPeriodMs < MEASURE_ALL_N_MILLIS / 64) timeUpToNextPeriodMs += MEASURE_ALL_N_MILLIS;
// remind what we did to use it in next round.
previousTriggerEpochMs += (timeUpToNextPeriodMs + MEASURE_ALL_N_MILLIS) % MEASURE_ALL_N_MILLIS;
// make state usable for next round.
while (previousTriggerEpochMs < nowMs) previousTriggerEpochMs += MEASURE_ALL_N_MILLIS;
log.debug("timeUpToNextPeriodMs is {}", timeUpToNextPeriodMs);
sleep(timeUpToNextPeriodMs);
// make a beep so consumers can notice if we died.
Expand Down

0 comments on commit 68a2a77

Please sign in to comment.