Kaydet (Commit) c0e0ae54 authored tarafından Caolán McNamara's avatar Caolán McNamara

use rtl::Static where double-locked pattern used

üst e8920fbe
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <rtl/alloc.h> #include <rtl/alloc.h>
#include <rtl/instance.hxx>
#include "osl/thread.h" #include "osl/thread.h"
#include <algorithm> #include <algorithm>
...@@ -90,19 +91,14 @@ LoggerGuard::~LoggerGuard() ...@@ -90,19 +91,14 @@ LoggerGuard::~LoggerGuard()
// g_buffer in init(): // g_buffer in init():
LoggerGuard loggerGuard; LoggerGuard loggerGuard;
Mutex & getLogMutex() namespace
{ {
static Mutex *pMutex = 0; class theLogMutex : public rtl::Static<osl::Mutex, theLogMutex>{};
if( !pMutex ) }
{
MutexGuard guard( Mutex::getGlobalMutex() ); static Mutex & getLogMutex()
if( ! pMutex ) {
{ return theLogMutex::get();
static Mutex mutex;
pMutex = &mutex;
}
}
return *pMutex;
} }
OUString getFileUrl( const OUString &name ) OUString getFileUrl( const OUString &name )
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <rtl/unload.h> #include <rtl/unload.h>
#include <rtl/alloc.h> #include <rtl/alloc.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <rtl/instance.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include "rtl/allocator.hxx" #include "rtl/allocator.hxx"
...@@ -109,19 +110,14 @@ static sal_Bool hasEnoughTimePassed( const TimeValue* unusedSince, const TimeVal ...@@ -109,19 +110,14 @@ static sal_Bool hasEnoughTimePassed( const TimeValue* unusedSince, const TimeVal
return retval; return retval;
} }
static osl::Mutex* getUnloadingMutex() namespace
{ {
static osl::Mutex * g_pMutex= NULL; class theUnloadingMutex : public rtl::Static<osl::Mutex, theUnloadingMutex>{};
if (!g_pMutex) }
{
MutexGuard guard( osl::Mutex::getGlobalMutex() ); static osl::Mutex& getUnloadingMutex()
if (!g_pMutex) {
{ return theUnloadingMutex::get();
static osl::Mutex g_aMutex;
g_pMutex= &g_aMutex;
}
}
return g_pMutex;
} }
extern "C" void rtl_moduleCount_acquire(rtl_ModuleCount * that ) extern "C" void rtl_moduleCount_acquire(rtl_ModuleCount * that )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment