Bug 998880: don't busy-wait in nsThread waiting for shutdown or DISPATCH_SYNC r=bsmedberg

This commit is contained in:
Randell Jesup 2014-04-22 15:34:24 -04:00
parent 1f9314c7a8
commit 04488d3bb4

View File

@ -463,8 +463,9 @@ nsThread::DispatchInternal(nsIRunnable *event, uint32_t flags,
if (NS_FAILED(rv))
return rv;
// Allows waiting; ensure no locks are held that would deadlock us!
while (wrapper->IsPending())
NS_ProcessNextEvent(thread);
NS_ProcessNextEvent(thread, true);
return wrapper->Result();
}
@ -539,8 +540,9 @@ nsThread::Shutdown()
// after setting mShutdownContext just before exiting.
// Process events on the current thread until we receive a shutdown ACK.
// Allows waiting; ensure no locks are held that would deadlock us!
while (!context.shutdownAck)
NS_ProcessNextEvent(context.joiningThread);
NS_ProcessNextEvent(context.joiningThread, true);
// Now, it should be safe to join without fear of dead-locking.