mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
re-run scheduler if only thread was still waiting (issue #594)
This commit is contained in:
parent
588d63d901
commit
3c8402d4fb
2 changed files with 11 additions and 4 deletions
|
@ -421,7 +421,7 @@ sexp sexp_scheduler (sexp ctx, sexp self, sexp_sint_t n, sexp root_thread) {
|
||||||
int i, k;
|
int i, k;
|
||||||
struct timeval tval;
|
struct timeval tval;
|
||||||
struct pollfd *pfds;
|
struct pollfd *pfds;
|
||||||
useconds_t usecs = 0;
|
suseconds_t usecs = 0;
|
||||||
sexp res, ls1, ls2, evt, runner, paused, front, pollfds;
|
sexp res, ls1, ls2, evt, runner, paused, front, pollfds;
|
||||||
sexp_gc_var1(tmp);
|
sexp_gc_var1(tmp);
|
||||||
sexp_gc_preserve1(ctx, tmp);
|
sexp_gc_preserve1(ctx, tmp);
|
||||||
|
@ -618,12 +618,15 @@ sexp sexp_scheduler (sexp ctx, sexp self, sexp_sint_t n, sexp root_thread) {
|
||||||
if (tval.tv_usec < sexp_context_timeval(res).tv_usec || usecs > 0)
|
if (tval.tv_usec < sexp_context_timeval(res).tv_usec || usecs > 0)
|
||||||
usecs += sexp_context_timeval(res).tv_usec - tval.tv_usec;
|
usecs += sexp_context_timeval(res).tv_usec - tval.tv_usec;
|
||||||
}
|
}
|
||||||
if (usecs > 10*1000) usecs = 10*1000;
|
if (usecs > 10*1000) {
|
||||||
|
usecs = 10*1000;
|
||||||
|
} else {
|
||||||
|
sexp_context_waitp(res) = 0;
|
||||||
|
sexp_context_timeoutp(res) = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* take a nap to avoid busy looping */
|
/* take a nap to avoid busy looping */
|
||||||
usleep(usecs);
|
usleep(usecs);
|
||||||
sexp_context_waitp(res) = 0;
|
|
||||||
sexp_context_timeoutp(res) = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sexp_gc_release1(ctx);
|
sexp_gc_release1(ctx);
|
||||||
|
|
4
vm.c
4
vm.c
|
@ -1066,6 +1066,10 @@ sexp sexp_apply (sexp ctx, sexp proc, sexp args) {
|
||||||
}
|
}
|
||||||
fuel = sexp_context_refuel(ctx);
|
fuel = sexp_context_refuel(ctx);
|
||||||
if (fuel <= 0) goto end_loop;
|
if (fuel <= 0) goto end_loop;
|
||||||
|
if (sexp_context_waitp(ctx)) {
|
||||||
|
fuel = 1;
|
||||||
|
goto loop; /* we were still waiting, try again */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if SEXP_USE_DEBUG_VM
|
#if SEXP_USE_DEBUG_VM
|
||||||
|
|
Loading…
Add table
Reference in a new issue