From 5b5b3ce352dcd6a4ae1a5b295aea13487d035418 Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 26 Feb 2004 16:21:36 +0000 Subject: [PATCH] [project @ 2004-02-26 16:21:36 by simonmar] merge rev. 1.6.2.3 from ghc-6-2-branch --- ghc/rts/win32/AwaitEvent.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ghc/rts/win32/AwaitEvent.c b/ghc/rts/win32/AwaitEvent.c index 92a84bc..edf65df 100644 --- a/ghc/rts/win32/AwaitEvent.c +++ b/ghc/rts/win32/AwaitEvent.c @@ -20,6 +20,10 @@ #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 - -- 1.7.10.4