Bug 1359833 - Part 0. Add SchedulerGroup::IsSafeToRunUnlabeled method to determine if running in an unlabeled context. r=billm
authorAndrew Osmond <aosmond@mozilla.com>
Wed, 19 Jul 2017 14:15:11 -0400
changeset 418432 ae4ec8080af6dbffc046e8699c8246f564046362
parent 418431 3e1508068c1b3158a3fb5373269922ef289dc5d4
child 418433 fd25a183897f665d70086ebd97033cb0f851c58c
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1359833
milestone56.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 1359833 - Part 0. Add SchedulerGroup::IsSafeToRunUnlabeled method to determine if running in an unlabeled context. r=billm
xpcom/threads/SchedulerGroup.h
--- a/xpcom/threads/SchedulerGroup.h
+++ b/xpcom/threads/SchedulerGroup.h
@@ -62,16 +62,24 @@ public:
   // 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() const
   {
     return !sRunningDispatcher || mAccessValid;
   }
 
+  // This function returns true if it's currently safe to run unlabeled code
+  // with no known SchedulerGroup. It will only return true if we're inside an
+  // unlabeled runnable.
+  static bool IsSafeToRunUnlabeled()
+  {
+    return !sRunningDispatcher;
+  }
+
   // Ensure that it's valid to access the TabGroup at this time.
   void ValidateAccess() const
   {
     MOZ_ASSERT(IsSafeToRun());
   }
 
   class Runnable final : public mozilla::Runnable
   {