fix Win32 build
[ghc-hetmet.git] / ghc / rts / win32 / AwaitEvent.c
index 92a84bc..43e188f 100644 (file)
@@ -1,3 +1,4 @@
+#if !defined(THREADED_RTS) /* to the end */
 /*
  * Wait/check for external events. Periodically, the
  * Scheduler checks for the completion of external operations,
  */
 #include "Rts.h"
 #include "Schedule.h"
+#include "AwaitEvent.h"
 #include <windows.h>
 #include "win32/AsyncIO.h"
-#if defined(RTS_SUPPORTS_THREADS)
-#include "Capability.h"
-#endif
+
+// Used to avoid calling abandonRequestWait() if we don't need to.
+// Protected by sched_mutex.
+static nat workerWaitingForRequests = 0;
 
 void
 awaitEvent(rtsBool wait)
 {
   int ret;
 
-#ifdef RTS_SUPPORTS_THREADS
-  // Small optimisation: we don't want the waiting thread to wake
-  // up straight away just because a previous returning worker has
-  // called abandonRequestWait().  If the event is no longer needed,
-  // reset it.  We must do this inside the sched_mutex.
-  if (!needToYieldToReturningWorker()) {
-      resetAbandonRequestWait();
-  }
-#endif
-
   do {
     /* Try to de-queue completed IO requests
      */
-    RELEASE_LOCK(&sched_mutex);
+    workerWaitingForRequests = 1;
     ret = awaitRequests(wait);
-    ACQUIRE_LOCK(&sched_mutex);
+    workerWaitingForRequests = 0;
     if (!ret) { 
       return; /* still hold the lock */
     }
@@ -49,22 +42,10 @@ awaitEvent(rtsBool wait)
     //
     //  - we were interrupted
     //  - new threads have arrived
-    //  - another worker wants to take over (RTS_SUPPORTS_THREADS)
 
   } while (wait
-          && !interrupted
-          && run_queue_hd == END_TSO_QUEUE
-#ifdef RTS_SUPPORTS_THREADS
-          && !needToYieldToReturningWorker()
-#endif
+          && sched_state == SCHED_RUNNING
+          && emptyRunQueue(&MainCapability)
       );
 }
-
-#ifdef RTS_SUPPORTS_THREADS
-void
-wakeBlockedWorkerThread()
-{
-  abandonRequestWait();
-}
 #endif
-