Closed skoriop closed 4 months ago
Thanks for the patch! Currently this does not handle suspend/resume situation. I think to fix this the timer's set_missed_tick_behavior
should be set to MissedTickBehavior::Skip
, at which point it's better to create a timer from duration instead of config.interval.timer()
shortcut.
Good point, I've added that change now.
Hm, that didn't work :(
My bad, I think I misunderstood your initial comment. Of the approaches I tried now, the only one that seems to work consistently is to move the phase adjusting logic into the loop
block.
No, no, you did exactly what I though. It's strange it didn't work, not sure why. Adjusting the phase in the loop is good too. Maybe we don't even need a timer then, and can just call sleep
?
Maybe we don't even need a timer then, and can just call
sleep
?
I think using interval
would be better here since it measures the time since the last tick while sleep
can be affected by the time spent in between calls (I couldn't tell the difference when using either, but it could become significant later if more code is added)
Closes #1991
Instead of snapping to the start (
:00
) of the next minute, it snaps to the nearest multiple of the interval value.For example, if the interval value is
5
and the config is initialized at:17
, the sequence shown will be:17
,:20
,:25
and so on.