mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-04 08:42:07 +00:00
Made musik::core::Preferences threadsafe.
This commit is contained in:
parent
25dfdd942d
commit
9be5738463
@ -41,6 +41,7 @@
|
|||||||
#include <core/db/CachedStatement.h>
|
#include <core/db/CachedStatement.h>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include <boost/thread/mutex.hpp>
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -48,10 +49,10 @@ using namespace musik::core;
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Preferences::Preferences(const char* nameSpace) :
|
Preferences::Preferences(const char* nameSpace)
|
||||||
nameSpace(nameSpace),
|
:nameSpace(nameSpace)
|
||||||
IOPtr(IO::Instance())
|
|
||||||
{
|
{
|
||||||
|
this->IOPtr = IO::Instance();
|
||||||
this->settings = this->IOPtr->GetNamespace(nameSpace);
|
this->settings = this->IOPtr->GetNamespace(nameSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +90,9 @@ utfstring Preferences::GetString(const char* key,const utfchar* defaultValue){
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Preferences::IO::Ptr Preferences::IO::Instance(){
|
Preferences::IO::Ptr Preferences::IO::Instance(){
|
||||||
|
static boost::mutex instanceMutex;
|
||||||
|
boost::mutex::scoped_lock oLock(instanceMutex);
|
||||||
|
|
||||||
static IO::Ptr sInstance(new Preferences::IO());
|
static IO::Ptr sInstance(new Preferences::IO());
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@ class Preferences{
|
|||||||
private:
|
private:
|
||||||
db::Connection db;
|
db::Connection db;
|
||||||
NamespaceMap namespaces;
|
NamespaceMap namespaces;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user