2 * Wait/check for external events. Periodically, the
3 * Scheduler checks for the completion of external operations,
4 * like the expiration of timers, completion of I/O requests
5 * issued by Haskell threads.
7 * If the Scheduler is otherwise out of work, it'll block
8 * herein waiting for external events to occur.
10 * This file mirrors the select()-based functionality
11 * for POSIX / Unix platforms in rts/Select.c, but for
18 #include "win32/AsyncIO.h"
21 awaitEvent(rtsBool wait)
23 RELEASE_LOCK(&sched_mutex);
25 /* Try to de-queue completed IO requests */
26 if (!awaitRequests(wait)) {
29 ACQUIRE_LOCK(&sched_mutex);
30 /* we were interrupted, return to the scheduler immediately.
33 return; /* still hold the lock */
36 /* If new runnable threads have arrived, stop waiting for
39 if (run_queue_hd != END_TSO_QUEUE) {
40 return; /* still hold the lock */
43 #ifdef RTS_SUPPORTS_THREADS
44 /* If another worker thread wants to take over,
45 * return to the scheduler
47 if (needToYieldToReturningWorker()) {
48 return; /* still hold the lock */
51 RELEASE_LOCK(&sched_mutex);
52 } while (wait && !interrupted && run_queue_hd == END_TSO_QUEUE);
55 #ifdef RTS_SUPPORTS_THREADS
57 wakeBlockedWorkerThread()