1 #if !defined(THREADED_RTS) /* to the end */
3 * Wait/check for external events. Periodically, the
4 * Scheduler checks for the completion of external operations,
5 * like the expiration of timers, completion of I/O requests
6 * issued by Haskell threads.
8 * If the Scheduler is otherwise out of work, it'll block
9 * herein waiting for external events to occur.
11 * This file mirrors the select()-based functionality
12 * for POSIX / Unix platforms in rts/Select.c, but for
18 #include "AwaitEvent.h"
20 #include "win32/AsyncIO.h"
22 // Used to avoid calling abandonRequestWait() if we don't need to.
23 // Protected by sched_mutex.
24 static nat workerWaitingForRequests = 0;
27 awaitEvent(rtsBool wait)
32 /* Try to de-queue completed IO requests
34 workerWaitingForRequests = 1;
35 ret = awaitRequests(wait);
36 workerWaitingForRequests = 0;
38 return; /* still hold the lock */
41 // Return to the scheduler if:
43 // - we were interrupted
44 // - new threads have arrived
47 && sched_state == SCHED_RUNNING
48 && emptyRunQueue(&MainCapability)