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"
21 #include "win32/ConsoleHandler.h"
23 // Used to avoid calling abandonRequestWait() if we don't need to.
24 // Protected by sched_mutex.
25 static nat workerWaitingForRequests = 0;
28 awaitEvent(rtsBool wait)
33 /* Try to de-queue completed IO requests
35 workerWaitingForRequests = 1;
36 ret = awaitRequests(wait);
37 workerWaitingForRequests = 0;
39 // If a signal was raised, we need to service it
40 // XXX the scheduler loop really should be calling
41 // startSignalHandlers(), but this is the way that posix/Select.c
42 // does it and I'm feeling too paranoid to refactor it today --SDM
43 if (stg_pending_events != 0) {
44 startSignalHandlers(&MainCapability);
49 return; /* still hold the lock */
52 // Return to the scheduler if:
54 // - we were interrupted
55 // - new threads have arrived
58 && sched_state == SCHED_RUNNING
59 && emptyRunQueue(&MainCapability)