mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Add a MutexRef class to clean up Mutex handling code
This commit is contained in:
@@ -36,13 +36,11 @@ Audio::PoolThread::PoolThread(Pool *pool)
|
||||
: pool(pool)
|
||||
, finish(false)
|
||||
{
|
||||
mutex = thread::newMutex();
|
||||
threadName = "AudioPool";
|
||||
}
|
||||
|
||||
Audio::PoolThread::~PoolThread()
|
||||
{
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
volatile bool finish;
|
||||
|
||||
// finish lock
|
||||
thread::Mutex *mutex;
|
||||
love::thread::MutexRef mutex;
|
||||
|
||||
public:
|
||||
PoolThread(Pool *pool);
|
||||
|
||||
@@ -32,7 +32,6 @@ namespace openal
|
||||
Pool::Pool()
|
||||
: sources()
|
||||
, totalSources(0)
|
||||
, mutex(nullptr)
|
||||
{
|
||||
// Clear errors.
|
||||
alGetError();
|
||||
@@ -53,9 +52,6 @@ Pool::Pool()
|
||||
if (totalSources < 4)
|
||||
throw love::Exception("Could not generate sources.");
|
||||
|
||||
// Create the mutex.
|
||||
mutex = thread::newMutex();
|
||||
|
||||
#ifdef AL_SOFT_direct_channels
|
||||
ALboolean hasext = alIsExtensionPresent("AL_SOFT_direct_channels");
|
||||
#endif
|
||||
@@ -79,8 +75,6 @@ Pool::~Pool()
|
||||
{
|
||||
stop();
|
||||
|
||||
delete mutex;
|
||||
|
||||
// Free all sources.
|
||||
alDeleteSources(totalSources, sources);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ private:
|
||||
|
||||
// Only one thread can access this object at the same time. This mutex will
|
||||
// make sure of that.
|
||||
thread::Mutex *mutex;
|
||||
love::thread::MutexRef mutex;
|
||||
|
||||
}; // Pool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user