[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> I'm going to apply the attached patch
This one, to be precise.
--- allegro/src/unix/uthreads.c 2004-07-09 12:17:04.000000000 +0200
+++ alleg_work/src/unix/uthreads.c 2004-07-11 18:07:39.000000000 +0200
@@ -65,23 +65,26 @@
{
struct timeval old_time, new_time;
struct timeval delay;
- unsigned long interval, i;
+ unsigned long interval;
int n;
block_all_signals();
+ interval = 0;
gettimeofday(&old_time, 0);
while (1) {
gettimeofday(&new_time, 0);
- interval = ((new_time.tv_sec - old_time.tv_sec) * 1000000L +
- (new_time.tv_usec - old_time.tv_usec));
+ /* add the new time difference to the remainder of the old difference */
+ interval += ((new_time.tv_sec - old_time.tv_sec) * 1000000L +
+ (new_time.tv_usec - old_time.tv_usec));
old_time = new_time;
- while (interval) {
- i = MIN (interval, INT_MAX/(TIMERS_PER_SECOND/100));
- interval -= i;
- i = i * (TIMERS_PER_SECOND/100) / 10000L;
+ /* run the callbacks for each 10ms elapsed, but limit to 18ms */
+ if (interval > 18000)
+ interval = 18000;
+ while (interval > 10000) {
+ interval -= 10000;
pthread_mutex_lock(&cli_mutex);
@@ -98,8 +101,9 @@
pthread_mutex_unlock(&cli_mutex);
}
+ /* rest a little bit before checking again */
delay.tv_sec = 0;
- delay.tv_usec = 10000;
+ delay.tv_usec = 1000;
select(0, NULL, NULL, NULL, &delay);
pthread_testcancel();
}