Bug 1363474 - Add a method to ask whether it's safe to run code related to a given SchedulerGroup (r=froydnj)
authorBill McCloskey <billm@mozilla.com>
Fri, 12 May 2017 14:50:55 -0700
changeset 359734 5ca9b0021c5b997e064354a93442aa3253c6545c
parent 359733 26b30ead4fbfc0866d6e4c05f027cf519827f953
child 359735 c36b97ad64701cea7a51d2b17d02afda4be89030
push id31855
push userarchaeopteryx@coole-files.de
push dateSat, 20 May 2017 16:49:13 +0000
treeherdermozilla-central@5b74bbf20e80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1363474
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1363474 - Add a method to ask whether it's safe to run code related to a given SchedulerGroup (r=froydnj) MozReview-Commit-ID: F8uZUTfUM9v
xpcom/threads/SchedulerGroup.h
--- a/xpcom/threads/SchedulerGroup.h
+++ b/xpcom/threads/SchedulerGroup.h
@@ -52,20 +52,29 @@ public:
   public:
     AutoProcessEvent();
     ~AutoProcessEvent();
 
   private:
     SchedulerGroup* mPrevRunningDispatcher;
   };
 
+  // This function returns true if it's currently safe to run code associated
+  // with this SchedulerGroup. It will return true either if we're inside an
+  // unlabeled runnable or if we're inside a runnable labeled with this
+  // SchedulerGroup.
+  bool IsSafeToRun()
+  {
+    return !sRunningDispatcher || mAccessValid;
+  }
+
   // Ensure that it's valid to access the TabGroup at this time.
   void ValidateAccess() const
   {
-    MOZ_ASSERT(!sRunningDispatcher || mAccessValid);
+    MOZ_ASSERT(IsSafeToRun());
   }
 
   class Runnable final : public mozilla::Runnable
   {
   public:
     Runnable(already_AddRefed<nsIRunnable>&& aRunnable,
              SchedulerGroup* aGroup);