Use PR_NotifyCondVar when only one worker thread needs to wake up, bug 785206. r=sstangl

This commit is contained in:
Brian Hackett 2012-08-23 17:47:18 -06:00
parent 93f90669cb
commit 965fd4a70b
2 changed files with 12 additions and 1 deletions

View File

@ -202,6 +202,13 @@ WorkerThreadState::wait(CondVar which, uint32_t millis)
void
WorkerThreadState::notify(CondVar which)
{
JS_ASSERT(isLocked());
PR_NotifyCondVar((which == MAIN) ? mainWakeup : helperWakeup);
}
void
WorkerThreadState::notifyAll(CondVar which)
{
JS_ASSERT(isLocked());
PR_NotifyAllCondVar((which == MAIN) ? mainWakeup : helperWakeup);
@ -218,8 +225,11 @@ WorkerThread::destroy()
{
AutoLockWorkerThreadState lock(runtime);
terminate = true;
state.notify(WorkerThreadState::WORKER);
/* Notify all workers, to ensure that this thread wakes up. */
state.notifyAll(WorkerThreadState::WORKER);
}
PR_JoinThread(thread);
}

View File

@ -55,6 +55,7 @@ struct WorkerThreadState
void wait(CondVar which, uint32_t timeoutMillis = 0);
void notify(CondVar which);
void notifyAll(CondVar which);
private: