azul
azul copied to clipboard
Fix for timers waiting a full interval before first run
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);
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.
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.
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.