Author |
Message |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Mar 10, 2006 3:25 pm Post subject: ml->SetTimer() |
 |
|
|
|
The design of this interface...
void (*SetTimer)(TimerFunc func, int initialdelay, int interval, void *param, void *key); |
assumes that the CALLED function wants control of repetition. The return value is used to indicate what to do. In general, I have found that the CALLING function knows more about what it wants. Therefore I propose the following change:
If the interval is set to 0 (zero), then the timer only triggers once. This only requires a change of one line of code in mainloop.c:
from:
if (td->killme || !ret)
to:
if (td->killme || !td->interval || !ret) |
I suppose this could conflict with those who expect a 0 (zero) interval to repeat as fast as the main loop is able. In that case, it would be possible to define something like:
and use it as an interval value. _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Fri Mar 10, 2006 7:04 pm Post subject: |
 |
|
|
|
I agree that it's a little strange, but I've never had a big problem with it. That's mostly because thus far my timer functions have been very closely tied to the calling function, meaning it doesn't matter who controls the rescheduling. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Grelminar Creator of Asss
Joined: Feb 26 2003 Posts: 378 Offline
|
Posted: Tue Mar 14, 2006 2:42 am Post subject: |
 |
|
|
|
I've also never wanted this functionality. Generally the calling and called functions are very closely coupled. But since it only adds functionality and doesn't break anything existing, I'll add it.
If you want to be called for each main loop iteration, register a CB_MAINLOOP callback, don't use a timer. |
|
Back to top |
|
 |
|