#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)
{
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 */
}
void
wakeBlockedWorkerThread()
{
- abandonRequestWait();
+ if (workerWaitingForRequests) {
+ abandonRequestWait();
+ }
}
#endif
-