mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Add a MutexRef class to clean up Mutex handling code
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -96,6 +96,18 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
class MutexRef
|
||||
{
|
||||
public:
|
||||
MutexRef();
|
||||
~MutexRef();
|
||||
|
||||
operator Mutex*() const;
|
||||
|
||||
private:
|
||||
Mutex *mutex;
|
||||
};
|
||||
|
||||
Mutex *newMutex();
|
||||
Conditional *newConditional();
|
||||
Thread *newThread(Threadable *t);
|
||||
|
||||
Reference in New Issue
Block a user