Kaydet (Commit) 9ed8a1bf authored tarafından Jochen Nitschke's avatar Jochen Nitschke Kaydeden (comit) Noel Grandin

replace double-checked locking patterns with thread safe ...

local statics.

Change-Id: Iab4963a04d15f06e9b1a36079a36d32453e09c8f
Reviewed-on: https://gerrit.libreoffice.org/61538
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 110781a3
...@@ -76,21 +76,13 @@ namespace basprov ...@@ -76,21 +76,13 @@ namespace basprov
static Sequence< OUString > getSupportedServiceNames_BasicProviderImpl() static Sequence< OUString > getSupportedServiceNames_BasicProviderImpl()
{ {
static Sequence< OUString >* pNames = nullptr; static Sequence< OUString > s_Names{
if ( !pNames ) "com.sun.star.script.provider.ScriptProviderForBasic",
{ "com.sun.star.script.provider.LanguageScriptProvider",
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); "com.sun.star.script.provider.ScriptProvider",
if ( !pNames ) "com.sun.star.script.browse.BrowseNode"};
{
static Sequence< OUString > aNames(4); return s_Names;
aNames.getArray()[0] = "com.sun.star.script.provider.ScriptProviderForBasic";
aNames.getArray()[1] = "com.sun.star.script.provider.LanguageScriptProvider";
aNames.getArray()[2] = "com.sun.star.script.provider.ScriptProvider";
aNames.getArray()[3] = "com.sun.star.script.browse.BrowseNode";
pNames = &aNames;
}
}
return *pNames;
} }
......
...@@ -176,18 +176,10 @@ namespace dlgprov ...@@ -176,18 +176,10 @@ namespace dlgprov
::osl::Mutex& getMutex() ::osl::Mutex& getMutex()
{
static ::osl::Mutex* s_pMutex = nullptr;
if ( !s_pMutex )
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
if ( !s_pMutex )
{ {
static ::osl::Mutex s_aMutex; static ::osl::Mutex s_aMutex;
s_pMutex = &s_aMutex;
} return s_aMutex;
}
return *s_pMutex;
} }
......
...@@ -62,17 +62,9 @@ namespace stringresource ...@@ -62,17 +62,9 @@ namespace stringresource
::osl::Mutex& getMutex() ::osl::Mutex& getMutex()
{ {
static ::osl::Mutex* s_pMutex = nullptr;
if ( !s_pMutex )
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
if ( !s_pMutex )
{
static ::osl::Mutex s_aMutex; static ::osl::Mutex s_aMutex;
s_pMutex = &s_aMutex;
} return s_aMutex;
}
return *s_pMutex;
} }
......
...@@ -838,19 +838,9 @@ SfxObjectShell* SfxObjectShell::GetObjectShell() ...@@ -838,19 +838,9 @@ SfxObjectShell* SfxObjectShell::GetObjectShell()
uno::Sequence< OUString > SfxObjectShell::GetEventNames() uno::Sequence< OUString > SfxObjectShell::GetEventNames()
{ {
static uno::Sequence< OUString >* pEventNameContainer = nullptr; static uno::Sequence< OUString > s_EventNameContainer(rtl::Reference<GlobalEventConfig>(new GlobalEventConfig)->getElementNames());
if ( !pEventNameContainer ) return s_EventNameContainer;
{
SolarMutexGuard aGuard;
if ( !pEventNameContainer )
{
static uno::Sequence< OUString > aEventNameContainer = rtl::Reference<GlobalEventConfig>(new GlobalEventConfig)->getElementNames();
pEventNameContainer = &aEventNameContainer;
}
}
return *pEventNameContainer;
} }
......
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