summaryrefslogtreecommitdiffstats
path: root/dom/workers/WorkerThread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/workers/WorkerThread.cpp')
-rw-r--r--dom/workers/WorkerThread.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/dom/workers/WorkerThread.cpp b/dom/workers/WorkerThread.cpp
index 19cf9cb364..14d944e4d3 100644
--- a/dom/workers/WorkerThread.cpp
+++ b/dom/workers/WorkerThread.cpp
@@ -13,6 +13,7 @@
#include "mozilla/Atomics.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/EventQueue.h"
+#include "mozilla/Logging.h"
#include "mozilla/MacroForEach.h"
#include "mozilla/NotNull.h"
#include "mozilla/ThreadEventQueue.h"
@@ -25,8 +26,15 @@
#include "nsIRunnable.h"
#include "nsIThreadInternal.h"
#include "nsString.h"
+#include "nsThreadUtils.h"
#include "prthread.h"
+static mozilla::LazyLogModule gWorkerThread("WorkerThread");
+#ifdef LOGV
+# undef LOGV
+#endif
+#define LOGV(msg) MOZ_LOG(gWorkerThread, LogLevel::Verbose, msg);
+
namespace mozilla {
using namespace ipc;
@@ -143,7 +151,11 @@ void WorkerThread::SetWorker(const WorkerThreadFriendKey& /* aKey */,
while (mOtherThreadsDispatchingViaEventTarget) {
mWorkerPrivateCondVar.Wait();
}
-
+ // Need to clean up the dispatched runnables if
+ // mOtherThreadsDispatchingViaEventTarget was non-zero.
+ if (NS_HasPendingEvents(nullptr)) {
+ NS_ProcessPendingEvents(nullptr);
+ }
#ifdef DEBUG
mAcceptingNonWorkerRunnables = true;
#endif
@@ -223,6 +235,8 @@ WorkerThread::Dispatch(already_AddRefed<nsIRunnable> aRunnable,
// May be called on any thread!
nsCOMPtr<nsIRunnable> runnable(aRunnable); // in case we exit early
+ LOGV(("WorkerThread::Dispatch [%p] runnable: %p", this, runnable.get()));
+
// Workers only support asynchronous dispatch.
if (NS_WARN_IF(aFlags != NS_DISPATCH_NORMAL)) {
return NS_ERROR_UNEXPECTED;
@@ -282,6 +296,8 @@ WorkerThread::Dispatch(already_AddRefed<nsIRunnable> aRunnable,
}
if (NS_WARN_IF(NS_FAILED(rv))) {
+ LOGV(("WorkerThread::Dispatch [%p] failed, runnable: %p", this,
+ runnable.get()));
return rv;
}