Commit bd885497 authored by Brian Hackett's avatar Brian Hackett
Browse files

Bug 1402595 - Don't wait on cooperative thread cvar after marking the current...

Bug 1402595 - Don't wait on cooperative thread cvar after marking the current thread as having finished, r=jandem.
parent 4b36b816
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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);
    });