Backout change 3285d8bef13f (
bug 1113429) due to backout of
bug 970307.
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -80,16 +80,17 @@
#include "nsJSEnvironment.h"
#include "nsJSUtils.h"
#include "nsNetUtil.h"
#include "nsPrintfCString.h"
#include "nsProxyRelease.h"
#include "nsQueryObject.h"
#include "nsSandboxFlags.h"
#include "prthread.h"
+#include "nsThread.h"
#include "xpcpublic.h"
#ifdef ANDROID
#include <android/log.h>
#endif
#ifdef DEBUG
#include "nsThreadManager.h"
@@ -5101,16 +5102,27 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
for (;;) {
Status currentStatus;
bool debuggerRunnablesPending = false;
bool normalRunnablesPending = false;
{
MutexAutoLock lock(mMutex);
+#ifdef MOZ_NUWA_PROCESS
+ {
+ nsThread *thr = static_cast<nsThread*>(NS_GetCurrentThread());
+ ReentrantMonitorAutoEnter mon(thr->ThreadStatusMonitor());
+ if (mControlQueue.IsEmpty() &&
+ !(normalRunnablesPending = NS_HasPendingEvents(mThread))) {
+ thr->SetIdle();
+ }
+ }
+#endif // MOZ_NUWA_PROCESS
+
while (mControlQueue.IsEmpty() &&
!(debuggerRunnablesPending = !mDebuggerQueue.IsEmpty()) &&
!(normalRunnablesPending = NS_HasPendingEvents(mThread))) {
WaitForWorkerEvents();
}
ProcessAllControlRunnablesLocked();
@@ -5637,25 +5649,16 @@ WorkerPrivate::WaitForWorkerEvents(PRInt
// Let the main thread know that the worker is blocked and that memory
// reporting may proceed.
mBlockedForMemoryReporter = true;
// The main thread may be waiting so we must notify.
mMemoryReportCondVar.Notify();
-#ifdef MOZ_NUWA_PROCESS
- {
- MOZ_ASSERT(mThread);
-
- ReentrantMonitorAutoEnter mon(mThread->ThreadStatusMonitor());
- mThread->SetIdle();
- }
-#endif // MOZ_NUWA_PROCESS
-
// Now wait for an actual worker event.
mCondVar.Wait(aInterval);
// We've gotten some kind of signal but we can't continue until the memory
// reporter has finished. Wait again.
while (mMemoryReporterRunning) {
mMemoryReportCondVar.Wait();
}