diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-04-03 21:04:22 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-04-03 21:43:48 +0100 |
commit | c0e0ae545baafb9bad697fc861450e120d59c9e1 (patch) | |
tree | cf87092461f5a89319603ee5f7c34ef4c229a241 /sal/rtl | |
parent | e8920fbe19a9164f00b476ad42243aaa081e8449 (diff) |
use rtl::Static where double-locked pattern used
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/source/logfile.cxx | 20 | ||||
-rw-r--r-- | sal/rtl/source/unload.cxx | 20 |
2 files changed, 16 insertions, 24 deletions
diff --git a/sal/rtl/source/logfile.cxx b/sal/rtl/source/logfile.cxx index 0e0f5e4b4063..f71d8f5be689 100644 --- a/sal/rtl/source/logfile.cxx +++ b/sal/rtl/source/logfile.cxx @@ -42,6 +42,7 @@ #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/alloc.h> +#include <rtl/instance.hxx> #include "osl/thread.h" #include <algorithm> @@ -90,19 +91,14 @@ LoggerGuard::~LoggerGuard() // g_buffer in init(): LoggerGuard loggerGuard; -Mutex & getLogMutex() +namespace { - static Mutex *pMutex = 0; - if( !pMutex ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pMutex ) - { - static Mutex mutex; - pMutex = &mutex; - } - } - return *pMutex; + class theLogMutex : public rtl::Static<osl::Mutex, theLogMutex>{}; +} + +static Mutex & getLogMutex() +{ + return theLogMutex::get(); } OUString getFileUrl( const OUString &name ) diff --git a/sal/rtl/source/unload.cxx b/sal/rtl/source/unload.cxx index d33de1a4ee66..2690973b7f28 100644 --- a/sal/rtl/source/unload.cxx +++ b/sal/rtl/source/unload.cxx @@ -31,6 +31,7 @@ #include <rtl/unload.h> #include <rtl/alloc.h> #include <rtl/ustring.hxx> +#include <rtl/instance.hxx> #include <osl/mutex.hxx> #include <boost/unordered_map.hpp> #include "rtl/allocator.hxx" @@ -109,19 +110,14 @@ static sal_Bool hasEnoughTimePassed( const TimeValue* unusedSince, const TimeVal return retval; } -static osl::Mutex* getUnloadingMutex() +namespace { - static osl::Mutex * g_pMutex= NULL; - if (!g_pMutex) - { - MutexGuard guard( osl::Mutex::getGlobalMutex() ); - if (!g_pMutex) - { - static osl::Mutex g_aMutex; - g_pMutex= &g_aMutex; - } - } - return g_pMutex; + class theUnloadingMutex : public rtl::Static<osl::Mutex, theUnloadingMutex>{}; +} + +static osl::Mutex& getUnloadingMutex() +{ + return theUnloadingMutex::get(); } extern "C" void rtl_moduleCount_acquire(rtl_ModuleCount * that ) |