From: Michael R. <mi...@re...> - 2010-02-04 15:16:58
|
Hi Martin, > I think you have gotten me wrong. The timers run pretty fine. The > problem is that each widget has its own timer with its own starting > time, so the widgets aren't synchronised to begin with. Ok, thanks for your explanation, now I got you! BUT (you know, there's alwys a BUT from my side ;-) I know this "timers getting out of sync" problem for years, never had the time to dig into that. While your modification surely solves this for widget updates, I want to get rid of it fundamentally. Apart from that, one (future) extension would be impossible: think of two widgets, both having an update timer of say 500 msec, but the second one is being pre-delayed by 250 msec (there is no such thing like a initial delay at the moment, but you never can tell with the future..) I think a clean solution would be to re-sync the timers. Given the fact that there should be no timer less that 10 msec, and that computers are fast these days, there shouldn't be a difference of mor than 1 or 2 msec. But they sum up with the current code. My idea would be to process not only the timer(s) that expired *now* but also timers that expire at now+5 msec, and set the "last time fired" timestamp for all these timers to *now*. the last point should be already in there: the timer_process() gets the current timestamp only once, at the very beginning. So "slow" callbacks would not affect the timing. Another needed functionality is already inside: the loop not only looks for timers that expire *now*, but also for timers that expired in the past. I can think of several possible solutions: a) when looking for expired timers, look a short period time into the future b) call timer_process() not exactly at the timeout of the next timer, but a bit later, so more timers would have expired. c) do some rounding of timeout values, probably depending on the delay timne (e.g. 10% of delay time) especially c) sounds interesting to me: if a timer has a timeout of 200 msec, round the next start time to 20msec, so it expires at 0:0200, 0:0400, 0:0600, .... I hope you all do understand what I'm talking about.... bye, Michael -- Michael Reinelt <mi...@re...> http://home.pages.at/reinelt GPG-Key 0xDF13BA50 ICQ #288386781 |