azul icon indicating copy to clipboard operation
azul copied to clipboard

Fix for timers waiting a full interval before first run

Open antonok-edm opened this issue 5 years ago • 3 comments

As per the documentation for delayed timers, a Timer should execute immediately when no delay is specified. However, if the timer is on an interval, it will wait a full interval before firing. This is especially problematic for timers with large intervals (e.g. querying a system's memory usage every 2 minutes).

This PR removes the initial interval delay. The old behavior is still possible by explicitly adding a delay, like so:

Timer::new(timer_function).with_delay(interval_time).with_interval(interval_time);

antonok-edm avatar Apr 17 '19 16:04 antonok-edm

Thanks for fixing it, but I'd rework the implementation a bit so it's easier to understand what's going on (and add comments for future maintainers). I'll do a review later.

fschutt avatar Apr 18 '19 04:04 fschutt

Just wanted to say, I haven't forgotten about this, but there are large refactorings in progress right now, may take a while to get merged.

fschutt avatar Apr 29 '19 22:04 fschutt

Yeah, I think I'll manually implement and check this again, I committed some huge files into git early on and needed to remove them via git-bfg, so this PR is kind of a mess right now sorry.

fschutt avatar Jun 19 '19 08:06 fschutt