Bug 1233743 - Remove the Mutex typedef from gfx/2d. r=vlad
authorNicolas Silva <nsilva@mozilla.com>
Mon, 21 Mar 2016 15:34:50 +0100
changeset 289657 39f16ff40154b473caaaeee44facbe94ee9755d5
parent 289656 a4494f43475d52282aed1532f1defb14685b6df8
child 289658 f88e164b9b29857f981906b4bbb80978f0960654
push id30108
push usercbook@mozilla.com
push dateTue, 22 Mar 2016 11:14:31 +0000
treeherdermozilla-central@ea6298e1b4f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs1233743
milestone48.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 1233743 - Remove the Mutex typedef from gfx/2d. r=vlad
gfx/2d/JobScheduler_posix.cpp
gfx/2d/JobScheduler_posix.h
--- a/gfx/2d/JobScheduler_posix.cpp
+++ b/gfx/2d/JobScheduler_posix.cpp
@@ -74,17 +74,17 @@ MultiThreadedJobQueue::WaitForJob(Job*& 
 {
   return PopJob(aOutJob, BLOCKING);
 }
 
 bool
 MultiThreadedJobQueue::PopJob(Job*& aOutJobs, AccessType aAccess)
 {
   for (;;) {
-    MutexAutoLock lock(&mMutex);
+    CriticalSectionAutoEnter lock(&mMutex);
 
     while (aAccess == BLOCKING && !mShuttingDown && mJobs.empty()) {
       mAvailableCondvar.Wait(&mMutex);
     }
 
     if (mShuttingDown) {
       return false;
     }
@@ -105,90 +105,90 @@ MultiThreadedJobQueue::PopJob(Job*& aOut
     return true;
   }
 }
 
 void
 MultiThreadedJobQueue::SubmitJob(Job* aJobs)
 {
   MOZ_ASSERT(aJobs);
-  MutexAutoLock lock(&mMutex);
+  CriticalSectionAutoEnter lock(&mMutex);
   mJobs.push_back(aJobs);
   mAvailableCondvar.Broadcast();
 }
 
 size_t
 MultiThreadedJobQueue::NumJobs()
 {
-  MutexAutoLock lock(&mMutex);
+  CriticalSectionAutoEnter lock(&mMutex);
   return mJobs.size();
 }
 
 bool
 MultiThreadedJobQueue::IsEmpty()
 {
-  MutexAutoLock lock(&mMutex);
+  CriticalSectionAutoEnter lock(&mMutex);
   return mJobs.empty();
 }
 
 void
 MultiThreadedJobQueue::ShutDown()
 {
-  MutexAutoLock lock(&mMutex);
+  CriticalSectionAutoEnter lock(&mMutex);
   mShuttingDown = true;
   while (mThreadsCount) {
     mAvailableCondvar.Broadcast();
     mShutdownCondvar.Wait(&mMutex);
   }
 }
 
 void
 MultiThreadedJobQueue::RegisterThread()
 {
   mThreadsCount += 1;
 }
 
 void
 MultiThreadedJobQueue::UnregisterThread()
 {
-  MutexAutoLock lock(&mMutex);
+  CriticalSectionAutoEnter lock(&mMutex);
   mThreadsCount -= 1;
   if (mThreadsCount == 0) {
     mShutdownCondvar.Broadcast();
   }
 }
 
 EventObject::EventObject()
 : mIsSet(false)
 {}
 
 EventObject::~EventObject()
 {}
 
 bool
 EventObject::Peak()
 {
-  MutexAutoLock lock(&mMutex);
+  CriticalSectionAutoEnter lock(&mMutex);
   return mIsSet;
 }
 
 void
 EventObject::Set()
 {
-  MutexAutoLock lock(&mMutex);
+  CriticalSectionAutoEnter lock(&mMutex);
   if (!mIsSet) {
     mIsSet = true;
     mCond.Broadcast();
   }
 }
 
 void
 EventObject::Wait()
 {
-  MutexAutoLock lock(&mMutex);
+  CriticalSectionAutoEnter lock(&mMutex);
   if (mIsSet) {
     return;
   }
   mCond.Wait(&mMutex);
 }
 
 } // namespce
 } // namespce
--- a/gfx/2d/JobScheduler_posix.h
+++ b/gfx/2d/JobScheduler_posix.h
@@ -21,33 +21,30 @@
 
 namespace mozilla {
 namespace gfx {
 
 class Job;
 class PosixCondVar;
 class WorkerThread;
 
-typedef mozilla::gfx::CriticalSection Mutex;
-typedef mozilla::gfx::CriticalSectionAutoEnter MutexAutoLock;
-
 // posix platforms only!
 class PosixCondVar {
 public:
   PosixCondVar() {
     DebugOnly<int> err = pthread_cond_init(&mCond, nullptr);
     MOZ_ASSERT(!err);
   }
 
   ~PosixCondVar() {
     DebugOnly<int> err = pthread_cond_destroy(&mCond);
     MOZ_ASSERT(!err);
   }
 
-  void Wait(Mutex* aMutex) {
+  void Wait(CriticalSection* aMutex) {
     DebugOnly<int> err = pthread_cond_wait(&mCond, &aMutex->mMutex);
     MOZ_ASSERT(!err);
   }
 
   void Broadcast() {
     DebugOnly<int> err = pthread_cond_broadcast(&mCond);
     MOZ_ASSERT(!err);
   }
@@ -96,17 +93,17 @@ public:
   void RegisterThread();
 
   // Worker threads
   void UnregisterThread();
 
 protected:
 
   std::list<Job*> mJobs;
-  Mutex mMutex;
+  CriticalSection mMutex;
   PosixCondVar mAvailableCondvar;
   PosixCondVar mShutdownCondvar;
   int32_t mThreadsCount;
   bool mShuttingDown;
 
   friend class WorkerThread;
 };
 
@@ -126,17 +123,17 @@ public:
 
   /// Return true if the event is set, without blocking.
   bool Peak();
 
   /// Set the event.
   void Set();
 
 protected:
-  Mutex mMutex;
+  CriticalSection mMutex;
   PosixCondVar mCond;
   bool mIsSet;
 };
 
 } // namespace
 } // namespace
 
 #include "JobScheduler.h"