[project @ 2004-02-26 16:21:36 by simonmar]
authorsimonmar <unknown>
Thu, 26 Feb 2004 16:21:36 +0000 (16:21 +0000)
committersimonmar <unknown>
Thu, 26 Feb 2004 16:21:36 +0000 (16:21 +0000)
merge rev. 1.6.2.3 from ghc-6-2-branch

ghc/rts/win32/AwaitEvent.c

index 92a84bc..edf65df 100644 (file)
 #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)
 {
@@ -38,9 +42,11 @@ awaitEvent(rtsBool wait)
   do {
     /* Try to de-queue completed IO requests
      */
+    workerWaitingForRequests = 1;
     RELEASE_LOCK(&sched_mutex);
     ret = awaitRequests(wait);
     ACQUIRE_LOCK(&sched_mutex);
+    workerWaitingForRequests = 0;
     if (!ret) { 
       return; /* still hold the lock */
     }
@@ -64,7 +70,8 @@ awaitEvent(rtsBool wait)
 void
 wakeBlockedWorkerThread()
 {
-  abandonRequestWait();
+    if (workerWaitingForRequests) {
+       abandonRequestWait();
+    }
 }
 #endif
-