Made musik::core::Preferences threadsafe.

This commit is contained in:
Daniel Önnerby 2008-08-11 06:58:31 +00:00
parent 25dfdd942d
commit 9be5738463
2 changed files with 8 additions and 3 deletions

View File

@ -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;
} }

View File

@ -104,6 +104,7 @@ class Preferences{
private: private:
db::Connection db; db::Connection db;
NamespaceMap namespaces; NamespaceMap namespaces;
}; };