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
17 #include "AwaitEvent.h"
19 #include "win32/AsyncIO.h"
21 // Used to avoid calling abandonRequestWait() if we don't need to.
22 // Protected by sched_mutex.
23 static nat workerWaitingForRequests = 0;
26 awaitEvent(rtsBool wait)
31 /* Try to de-queue completed IO requests
33 workerWaitingForRequests = 1;
34 ret = awaitRequests(wait);
35 workerWaitingForRequests = 0;
37 return; /* still hold the lock */
40 // Return to the scheduler if:
42 // - we were interrupted
43 // - new threads have arrived
47 && emptyRunQueue(&MainCapability)