diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-04-03 21:34:16 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-04-03 21:43:01 +0100 |
commit | f183d3a500626354508993d453e265da9614df45 (patch) | |
tree | 9ce9e5dc75b002d1901f905083c66eeaaa3799ff /unotools/source/config/moduleoptions.cxx | |
parent | 41d271db85a1adec8591f08b969695c0f7885356 (diff) |
use rtl::Static where double-locked pattern used
Diffstat (limited to 'unotools/source/config/moduleoptions.cxx')
-rw-r--r-- | unotools/source/config/moduleoptions.cxx | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/unotools/source/config/moduleoptions.cxx b/unotools/source/config/moduleoptions.cxx index 4edb4fb0968e..c275a910510e 100644 --- a/unotools/source/config/moduleoptions.cxx +++ b/unotools/source/config/moduleoptions.cxx @@ -38,6 +38,7 @@ #include <rtl/ustrbuf.hxx> #include <rtl/logfile.hxx> +#include <rtl/instance.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> @@ -1278,6 +1279,10 @@ sal_uInt32 SvtModuleOptions::GetFeatures() const return nFeature; } +namespace +{ + class theModuleOptionsMutex : public rtl::Static<osl::Mutex, theModuleOptionsMutex> {}; +} /*-****************************************************************************************************//** @short return a reference to a static mutex @descr These class is threadsafe. @@ -1294,24 +1299,7 @@ sal_uInt32 SvtModuleOptions::GetFeatures() const *//*-*****************************************************************************************************/ ::osl::Mutex& SvtModuleOptions::impl_GetOwnStaticMutex() { - // Initialize static mutex only for one time! - static ::osl::Mutex* pMutex = NULL; - // If these method first called (Mutex not already exist!) ... - if( pMutex == NULL ) - { - // ... we must create a new one. Protect follow code with the global mutex - - // It must be - we create a static variable! - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! - if( pMutex == NULL ) - { - // Create the new mutex and set it for return on static variable. - static ::osl::Mutex aMutex; - pMutex = &aMutex; - } - } - // Return new created or already existing mutex object. - return *pMutex; + return theModuleOptionsMutex::get(); } ::rtl::OUString SvtModuleOptions::GetModuleName( EModule eModule ) const |