Re: [AD] SetTimer for the timer

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Monday 09 January 2006 01:37, Peter Wang wrote:
> Apparently it is not very accurate though.

Unfortuante. :( Though I wouldn't call the NT/2K/XP accuracy very bad, 
considering that's about as accurate as it is now. The message priority is a 
problem, though. Is there any way to increase the accuracy for 9x and 
increase the message priority? Or are those hard-coded?

> > It seems these would fit better than the current hackish way
> > of running a timed thread.
>
> Why is it hackish?  It's pretty straight forward.

Because they were originally designed to run in an interupt context, not 
concurrently with the main program (which has led to sloppiness and the 
mistaken belief that you can wait in a timer for something to occur in the 
main thread; eg. a mutex). To put it into perspective, if the timer was 
accurate and better prioritized so it would be used, anything that uses the 
software mouse or calls a sound/graphic function would randomly freeze solid. 
Granted the latter shouldn't be done anyway, and the former would hopefully 
be fixed in some way, but the current implementation clearly allows it.

As well, there's problems making a single thread having to keep track of all 
the timers which can have different speeds. This is either handled by 
sleeping at the lowest-common-multiple and checking each function upon wakeup 
which would cause it to recheck needlessly often when using two speeds that 
don't cleanly divide, or by dynamically calculating the time until the next 
interrupt would occur (current implementation, I believe) which causes more 
delayed jitter which is expounded by the sleeping function's inherent 
innacuracy.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/