X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2Fwin32%2FAwaitEvent.c;h=92a84bcb965c780d25d61eb968466fd8a72fe4d8;hb=e807565a9792b31ed02e37fd837375840be6a22f;hp=0df8023e8694345f78b275f5bcefdd89f46eddfe;hpb=622da08564f02443b40426a19c25f82e89071cac;p=ghc-hetmet.git diff --git a/ghc/rts/win32/AwaitEvent.c b/ghc/rts/win32/AwaitEvent.c index 0df8023..92a84bc 100644 --- a/ghc/rts/win32/AwaitEvent.c +++ b/ghc/rts/win32/AwaitEvent.c @@ -25,6 +25,16 @@ 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 */ @@ -35,28 +45,19 @@ awaitEvent(rtsBool wait) return; /* still hold the lock */ } - /* we were interrupted, return to the scheduler immediately. - */ - if (interrupted) { - return; /* still hold the lock */ - } - - /* If new runnable threads have arrived, stop waiting for - * I/O and run them. - */ - if (run_queue_hd != END_TSO_QUEUE) { - return; /* still hold the lock */ - } + // Return to the scheduler if: + // + // - 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 - /* If another worker thread wants to take over, - * return to the scheduler - */ - if (needToYieldToReturningWorker()) { - return; /* still hold the lock */ - } + && !needToYieldToReturningWorker() #endif - } while (wait && !interrupted && run_queue_hd == END_TSO_QUEUE); + ); } #ifdef RTS_SUPPORTS_THREADS