diff options
Diffstat (limited to 'src/timer.c')
-rw-r--r-- | src/timer.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/timer.c b/src/timer.c index 4b07d27..d3ff656 100644 --- a/src/timer.c +++ b/src/timer.c @@ -153,24 +153,32 @@ void TimerScan() int timer_echu = 0; stamp = currentTime(); + /* recherche des timers echu dans la liste */ IVY_LIST_EACH_SAFE( timers , timer, next ) { - if ( timer->when <= stamp ) + if ( timer->when <= stamp ) + { + timer_echu++; + delta = stamp - timer->when; + /* call callback */ + (*timer->callback)( timer, timer->user_data, delta ); + } + } + + IVY_LIST_EACH_SAFE( timers , timer, next ) + { + if ( timer->when <= stamp ) + { + if ( timer->repeat == TIMER_LOOP || --(timer->repeat) ) + { + timer->when = stamp + timer->period; + } + else { - timer_echu++; - delta = stamp - timer->when; - /* call callback */ - (*timer->callback)( timer, timer->user_data, delta ); - if ( timer->repeat == TIMER_LOOP || --(timer->repeat) ) - { - timer->when = stamp + timer->period; - } - else - { - IVY_LIST_REMOVE( timers, timer ); - } + IVY_LIST_REMOVE( timers, timer ); } + } } } |