summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2018-10-08 16:32:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-08 19:51:24 +0200
commit9ed8a1bfffd608b31badeae5341ebf0b48501419 (patch)
treec0ed025295bdde4eb960aa522fecc87a60b4000d /scripting
parent110781a3a27dffe9e6690839bdce993796a08331 (diff)
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: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/basprov/basprov.cxx22
-rw-r--r--scripting/source/dlgprov/dlgprov.cxx14
-rw-r--r--scripting/source/stringresource/stringresource.cxx14
3 files changed, 13 insertions, 37 deletions
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx
index 6180fa333627..ce71c003d75d 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -76,21 +76,13 @@ namespace basprov
static Sequence< OUString > getSupportedServiceNames_BasicProviderImpl()
{
- static Sequence< OUString >* pNames = nullptr;
- if ( !pNames )
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if ( !pNames )
- {
- static Sequence< OUString > aNames(4);
- 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;
+ static Sequence< OUString > s_Names{
+ "com.sun.star.script.provider.ScriptProviderForBasic",
+ "com.sun.star.script.provider.LanguageScriptProvider",
+ "com.sun.star.script.provider.ScriptProvider",
+ "com.sun.star.script.browse.BrowseNode"};
+
+ return s_Names;
}
diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx
index 90a28cca56fd..4f979ee54308 100644
--- a/scripting/source/dlgprov/dlgprov.cxx
+++ b/scripting/source/dlgprov/dlgprov.cxx
@@ -177,17 +177,9 @@ namespace dlgprov
::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;
- s_pMutex = &s_aMutex;
- }
- }
- return *s_pMutex;
+ static ::osl::Mutex s_aMutex;
+
+ return s_aMutex;
}
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index a17977536056..9e29229e13e0 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -62,17 +62,9 @@ namespace stringresource
::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;
- s_pMutex = &s_aMutex;
- }
- }
- return *s_pMutex;
+ static ::osl::Mutex s_aMutex;
+
+ return s_aMutex;
}