Bug 1402595 - Don't wait on cooperative thread cvar after marking the current thread as having finished, r=jandem.

This commit is contained in:
Brian Hackett 2017-11-01 09:56:59 -06:00
Родитель 4b36b816ed
Коммит bd8854975b
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -3383,7 +3383,7 @@ CooperativeEndWait(JSContext* cx)
}
static void
CooperativeYield()
CooperativeYield(bool terminating = false)
{
LockGuard<Mutex> lock(cooperationState->lock);
MOZ_ASSERT(!cooperationState->idle);
@ -3392,7 +3392,7 @@ CooperativeYield()
// Wait until another thread takes over control before returning, if there
// is another thread to do so.
if (cooperationState->numThreads) {
if (!terminating && cooperationState->numThreads) {
uint64_t count = cooperationState->yieldCount;
cooperationState->cvar.wait(lock, [&] { return cooperationState->yieldCount != count; });
}
@ -3552,7 +3552,7 @@ WorkerMain(void* arg)
js_delete(sc);
if (input->siblingContext) {
cooperationState->numThreads--;
CooperativeYield();
CooperativeYield(/* terminating = */ true);
}
js_delete(input);
});