Bug 1347963 - part 5 - make ChannelEventQueue use RecursiveMutex; r=mcmanus
authorNathan Froyd <froydnj@mozilla.com>
Tue, 04 Jul 2017 13:43:47 -0400
changeset 420024 069e7b402e3df80b74a6174cb8e42ca7ffdbf2e9
parent 420023 b9bd9b93f78693726cdb7ccfa7364c1e40c93f49
child 420025 6c1336c071ccf412d4e85887c8f55bae683429da
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)
reviewersmcmanus
bugs1347963
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 1347963 - part 5 - make ChannelEventQueue use RecursiveMutex; r=mcmanus Making ChannelEventQueue slightly faster with RecursiveMutex is a good thing.
netwerk/ipc/ChannelEventQueue.h
--- a/netwerk/ipc/ChannelEventQueue.h
+++ b/netwerk/ipc/ChannelEventQueue.h
@@ -10,17 +10,17 @@
 
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "nsIEventTarget.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Mutex.h"
-#include "mozilla/ReentrantMonitor.h"
+#include "mozilla/RecursiveMutex.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Unused.h"
 
 class nsISupports;
 
 namespace mozilla {
 namespace net {
 
@@ -94,17 +94,17 @@ class ChannelEventQueue final
  public:
   explicit ChannelEventQueue(nsISupports *owner)
     : mSuspendCount(0)
     , mSuspended(false)
     , mForcedCount(0)
     , mFlushing(false)
     , mOwner(owner)
     , mMutex("ChannelEventQueue::mMutex")
-    , mRunningMonitor("ChannelEventQueue::mRunningMonitor")
+    , mRunningMutex("ChannelEventQueue::mRunningMutex")
   {}
 
   // Puts IPDL-generated channel event into queue, to be run later
   // automatically when EndForcedQueueing and/or Resume is called.
   //
   // @param aCallback - the ChannelEvent
   // @param aAssertionWhenNotQueued - this optional param will be used in an
   //   assertion when the event is executed directly.
@@ -155,17 +155,17 @@ class ChannelEventQueue final
 
   // Keep ptr to avoid refcount cycle: only grab ref during flushing.
   nsISupports *mOwner;
 
   // For atomic mEventQueue operation and state update
   Mutex mMutex;
 
   // To guarantee event execution order among threads
-  ReentrantMonitor mRunningMonitor;
+  RecursiveMutex mRunningMutex;
 
   friend class AutoEventEnqueuer;
 };
 
 inline void
 ChannelEventQueue::RunOrEnqueue(ChannelEvent* aCallback,
                                 bool aAssertionWhenNotQueued)
 {
@@ -177,17 +177,17 @@ ChannelEventQueue::RunOrEnqueue(ChannelE
   nsCOMPtr<nsISupports> kungFuDeathGrip(mOwner);
   Unused << kungFuDeathGrip; // Not used in this function
 
   // To avoid leaks.
   UniquePtr<ChannelEvent> event(aCallback);
 
   // To guarantee that the running event and all the events generated within
   // it will be finished before events on other threads.
-  ReentrantMonitorAutoEnter monitor(mRunningMonitor);
+  RecursiveMutexAutoLock lock(mRunningMutex);
 
   {
     MutexAutoLock lock(mMutex);
 
     bool enqueue =  !!mForcedCount || mSuspended || mFlushing || !mEventQueue.IsEmpty();
 
     if (enqueue) {
       mEventQueue.AppendElement(Move(event));