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
-2
View File
@@ -36,13 +36,11 @@ Audio::PoolThread::PoolThread(Pool *pool)
: pool(pool)
, finish(false)
{
mutex = thread::newMutex();
threadName = "AudioPool";
}
Audio::PoolThread::~PoolThread()
{
delete mutex;
}
+1 -1
View File
@@ -126,7 +126,7 @@ private:
volatile bool finish;
// finish lock
thread::Mutex *mutex;
love::thread::MutexRef mutex;
public:
PoolThread(Pool *pool);
-6
View File
@@ -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);
}
+1 -1
View File
@@ -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