From 3d89d1e8b9b623a641629668a87619b0538a0003 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 10 Apr 2015 11:52:08 -0700 Subject: [PATCH] Bug 1153370 - Rescope monitor. r=jww We can do this now that we're not manually nulling out mRunningThread anymore. --- dom/media/MediaTaskQueue.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/dom/media/MediaTaskQueue.cpp b/dom/media/MediaTaskQueue.cpp index fca8eb5c1a06..a7c1f1920594 100644 --- a/dom/media/MediaTaskQueue.cpp +++ b/dom/media/MediaTaskQueue.cpp @@ -275,19 +275,13 @@ MediaTaskQueue::Runner::Run() // run in a loop here so that we don't hog the thread pool. This means we may // run on another thread next time, but we rely on the memory fences from // mQueueMonitor for thread safety of non-threadsafe tasks. - { + nsresult rv = mQueue->mPool->Dispatch(this, NS_DISPATCH_NORMAL); + if (NS_FAILED(rv)) { + // Failed to dispatch, shutdown! MonitorAutoLock mon(mQueue->mQueueMonitor); - // Note: Hold the monitor *before* we dispatch, in case we context switch - // to another thread pool in the queue immediately and take the lock in the - // other thread; mRunningThread could be set to the new thread's value and - // then incorrectly anulled below in that case. - nsresult rv = mQueue->mPool->Dispatch(this, NS_DISPATCH_NORMAL); - if (NS_FAILED(rv)) { - // Failed to dispatch, shutdown! - mQueue->mIsRunning = false; - mQueue->mIsShutdown = true; - mon.NotifyAll(); - } + mQueue->mIsRunning = false; + mQueue->mIsShutdown = true; + mon.NotifyAll(); } return NS_OK;