Bug 1233743 - Remove the Mutex typedef from gfx/2d. r=vlad

This commit is contained in:
Nicolas Silva 2016-03-21 15:34:50 +01:00
parent aa0d228da1
commit f06dc39683
2 changed files with 12 additions and 15 deletions

View File

@ -79,7 +79,7 @@ bool
MultiThreadedJobQueue::PopJob(Job*& aOutJobs, AccessType aAccess) MultiThreadedJobQueue::PopJob(Job*& aOutJobs, AccessType aAccess)
{ {
for (;;) { for (;;) {
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
while (aAccess == BLOCKING && !mShuttingDown && mJobs.empty()) { while (aAccess == BLOCKING && !mShuttingDown && mJobs.empty()) {
mAvailableCondvar.Wait(&mMutex); mAvailableCondvar.Wait(&mMutex);
@ -110,7 +110,7 @@ void
MultiThreadedJobQueue::SubmitJob(Job* aJobs) MultiThreadedJobQueue::SubmitJob(Job* aJobs)
{ {
MOZ_ASSERT(aJobs); MOZ_ASSERT(aJobs);
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
mJobs.push_back(aJobs); mJobs.push_back(aJobs);
mAvailableCondvar.Broadcast(); mAvailableCondvar.Broadcast();
} }
@ -118,21 +118,21 @@ MultiThreadedJobQueue::SubmitJob(Job* aJobs)
size_t size_t
MultiThreadedJobQueue::NumJobs() MultiThreadedJobQueue::NumJobs()
{ {
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
return mJobs.size(); return mJobs.size();
} }
bool bool
MultiThreadedJobQueue::IsEmpty() MultiThreadedJobQueue::IsEmpty()
{ {
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
return mJobs.empty(); return mJobs.empty();
} }
void void
MultiThreadedJobQueue::ShutDown() MultiThreadedJobQueue::ShutDown()
{ {
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
mShuttingDown = true; mShuttingDown = true;
while (mThreadsCount) { while (mThreadsCount) {
mAvailableCondvar.Broadcast(); mAvailableCondvar.Broadcast();
@ -149,7 +149,7 @@ MultiThreadedJobQueue::RegisterThread()
void void
MultiThreadedJobQueue::UnregisterThread() MultiThreadedJobQueue::UnregisterThread()
{ {
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
mThreadsCount -= 1; mThreadsCount -= 1;
if (mThreadsCount == 0) { if (mThreadsCount == 0) {
mShutdownCondvar.Broadcast(); mShutdownCondvar.Broadcast();
@ -166,14 +166,14 @@ EventObject::~EventObject()
bool bool
EventObject::Peak() EventObject::Peak()
{ {
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
return mIsSet; return mIsSet;
} }
void void
EventObject::Set() EventObject::Set()
{ {
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
if (!mIsSet) { if (!mIsSet) {
mIsSet = true; mIsSet = true;
mCond.Broadcast(); mCond.Broadcast();
@ -183,7 +183,7 @@ EventObject::Set()
void void
EventObject::Wait() EventObject::Wait()
{ {
MutexAutoLock lock(&mMutex); CriticalSectionAutoEnter lock(&mMutex);
if (mIsSet) { if (mIsSet) {
return; return;
} }

View File

@ -26,9 +26,6 @@ class Job;
class PosixCondVar; class PosixCondVar;
class WorkerThread; class WorkerThread;
typedef mozilla::gfx::CriticalSection Mutex;
typedef mozilla::gfx::CriticalSectionAutoEnter MutexAutoLock;
// posix platforms only! // posix platforms only!
class PosixCondVar { class PosixCondVar {
public: public:
@ -42,7 +39,7 @@ public:
MOZ_ASSERT(!err); MOZ_ASSERT(!err);
} }
void Wait(Mutex* aMutex) { void Wait(CriticalSection* aMutex) {
DebugOnly<int> err = pthread_cond_wait(&mCond, &aMutex->mMutex); DebugOnly<int> err = pthread_cond_wait(&mCond, &aMutex->mMutex);
MOZ_ASSERT(!err); MOZ_ASSERT(!err);
} }
@ -101,7 +98,7 @@ public:
protected: protected:
std::list<Job*> mJobs; std::list<Job*> mJobs;
Mutex mMutex; CriticalSection mMutex;
PosixCondVar mAvailableCondvar; PosixCondVar mAvailableCondvar;
PosixCondVar mShutdownCondvar; PosixCondVar mShutdownCondvar;
int32_t mThreadsCount; int32_t mThreadsCount;
@ -131,7 +128,7 @@ public:
void Set(); void Set();
protected: protected:
Mutex mMutex; CriticalSection mMutex;
PosixCondVar mCond; PosixCondVar mCond;
bool mIsSet; bool mIsSet;
}; };