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)
{
for (;;) {
MutexAutoLock lock(&mMutex);
CriticalSectionAutoEnter lock(&mMutex);
while (aAccess == BLOCKING && !mShuttingDown && mJobs.empty()) {
mAvailableCondvar.Wait(&mMutex);
@ -110,7 +110,7 @@ void
MultiThreadedJobQueue::SubmitJob(Job* aJobs)
{
MOZ_ASSERT(aJobs);
MutexAutoLock lock(&mMutex);
CriticalSectionAutoEnter lock(&mMutex);
mJobs.push_back(aJobs);
mAvailableCondvar.Broadcast();
}
@ -118,21 +118,21 @@ MultiThreadedJobQueue::SubmitJob(Job* aJobs)
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();
@ -149,7 +149,7 @@ MultiThreadedJobQueue::RegisterThread()
void
MultiThreadedJobQueue::UnregisterThread()
{
MutexAutoLock lock(&mMutex);
CriticalSectionAutoEnter lock(&mMutex);
mThreadsCount -= 1;
if (mThreadsCount == 0) {
mShutdownCondvar.Broadcast();
@ -166,14 +166,14 @@ 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();
@ -183,7 +183,7 @@ EventObject::Set()
void
EventObject::Wait()
{
MutexAutoLock lock(&mMutex);
CriticalSectionAutoEnter lock(&mMutex);
if (mIsSet) {
return;
}

View File

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