mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 06:09:18 +02:00
fix to avoid maxing cpu when we want to wait on an fd
This commit is contained in:
parent
3b116b3189
commit
cd91d4aa72
1 changed files with 11 additions and 0 deletions
|
@ -517,7 +517,18 @@ sexp sexp_scheduler (sexp ctx, sexp self, sexp_sint_t n, sexp root_thread) {
|
|||
sexp_cdr(sexp_global(ctx, SEXP_G_THREADS_BACK)) = SEXP_NULL;
|
||||
}
|
||||
} else {
|
||||
/* no threads to dequeue */
|
||||
res = ctx;
|
||||
/* prefer a thread we can wait on instead of spinning */
|
||||
if (sexp_context_refuel(ctx) <= 0) {
|
||||
for (ls1=paused; sexp_pairp(ls1); ls1=sexp_cdr(ls1)) {
|
||||
evt = sexp_context_event(sexp_car(ls1));
|
||||
if (sexp_fixnump(evt) || sexp_portp(evt)) {
|
||||
res = sexp_car(ls1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sexp_context_waitp(res)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue