Add a MutexRef class to clean up Mutex handling code

This commit is contained in:
Bart van Strien
2015-07-06 11:58:08 +02:00
parent dd1167d736
commit 7e44034757
10 changed files with 31 additions and 21 deletions
+15
View File
@@ -104,5 +104,20 @@ const char *Threadable::getThreadName() const
return threadName.empty() ? nullptr : threadName.c_str();
}
MutexRef::MutexRef()
: mutex(newMutex())
{
}
MutexRef::~MutexRef()
{
delete mutex;
}
MutexRef::operator Mutex*() const
{
return mutex;
}
} // thread
} // love
+12
View File
@@ -96,6 +96,18 @@ protected:
};
class MutexRef
{
public:
MutexRef();
~MutexRef();
operator Mutex*() const;
private:
Mutex *mutex;
};
Mutex *newMutex();
Conditional *newConditional();
Thread *newThread(Threadable *t);