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"
19 #if defined(RTS_SUPPORTS_THREADS)
20 #include "Capability.h"
24 awaitEvent(rtsBool wait)
29 /* Try to de-queue completed IO requests
31 RELEASE_LOCK(&sched_mutex);
32 ret = awaitRequests(wait);
33 ACQUIRE_LOCK(&sched_mutex);
35 return; /* still hold the lock */
38 /* we were interrupted, return to the scheduler immediately.
41 return; /* still hold the lock */
44 /* If new runnable threads have arrived, stop waiting for
47 if (run_queue_hd != END_TSO_QUEUE) {
48 return; /* still hold the lock */
51 #ifdef RTS_SUPPORTS_THREADS
52 /* If another worker thread wants to take over,
53 * return to the scheduler
55 if (needToYieldToReturningWorker()) {
56 return; /* still hold the lock */
59 } while (wait && !interrupted && run_queue_hd == END_TSO_QUEUE);
62 #ifdef RTS_SUPPORTS_THREADS
64 wakeBlockedWorkerThread()