Bug 1315187 - Assert that thread calling IdleDispatch is the thread that will run it. r?smaug draft
authorAndreas Farre <farre@mozilla.com>
Fri, 04 Nov 2016 09:08:31 +0100
changeset 433765 3c8cd3400986392e9f5a3da75ccf521956ce926b
parent 433745 561b87e98adacbd47769a71a0e6c72c5dcf66a9d
child 434885 87c71d2eb6125ac1c0a88a8b4caf089adf04f020
push id34643
push userbmo:afarre@mozilla.com
push dateFri, 04 Nov 2016 08:10:31 +0000
reviewerssmaug
bugs1315187
milestone52.0a1
Bug 1315187 - Assert that thread calling IdleDispatch is the thread that will run it. r?smaug MozReview-Commit-ID: LGrKeIUaGCD
xpcom/threads/nsThread.cpp
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -977,16 +977,22 @@ nsThread::RegisterIdlePeriod(already_Add
   MutexAutoLock lock(mLock);
   mIdlePeriod = aIdlePeriod;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsThread::IdleDispatch(already_AddRefed<nsIRunnable> aEvent)
 {
+  // Currently the only supported idle dispatch is from the same
+  // thread. To support idle dispatch from another thread we need to
+  // support waking threads that are waiting for an event queue that
+  // isn't mIdleEvents.
+  MOZ_ASSERT(PR_GetCurrentThread() == mThread);
+
   MutexAutoLock lock(mLock);
   LeakRefPtr<nsIRunnable> event(Move(aEvent));
 
   if (NS_WARN_IF(!event)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   if (mEventsAreDoomed) {