diff --git a/racket/src/thread/schedule.rkt b/racket/src/thread/schedule.rkt index f18c7c7744..d75d4f7177 100644 --- a/racket/src/thread/schedule.rkt +++ b/racket/src/thread/schedule.rkt @@ -55,22 +55,22 @@ (set! thread-swap-count 0)) (define (select-thread! [pending-callbacks null]) + (define callbacks (if (null? pending-callbacks) + (host:poll-async-callbacks) + pending-callbacks)) + (host:poll-will-executors) + (poll-custodian-will-executor) + (check-external-events 'fast) + (call-pre-poll-external-callbacks) + (check-place-activity) + (check-queued-custodian-shutdown) + (when (and (null? callbacks) + (all-threads-poll-done?) + (waiting-on-external-or-idle?)) + (or (check-external-events 'slow) + (try-post-idle) + (process-sleep))) (let loop ([g root-thread-group] [pending-callbacks pending-callbacks] [none-k maybe-done]) - (define callbacks (if (null? pending-callbacks) - (host:poll-async-callbacks) - pending-callbacks)) - (host:poll-will-executors) - (poll-custodian-will-executor) - (check-external-events 'fast) - (call-pre-poll-external-callbacks) - (check-place-activity) - (check-queued-custodian-shutdown) - (when (and (null? callbacks) - (all-threads-poll-done?) - (waiting-on-external-or-idle?)) - (or (check-external-events 'slow) - (try-post-idle) - (process-sleep))) (define child (thread-group-next! g)) (cond [(not child) (none-k callbacks)]