summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2017-06-17 14:01:36 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-17 15:43:38 +0200
commit6149da20ddee5c0c50b445fb6a4e3e81b5ff900b (patch)
tree7cfca9c16dff522f0c0e15809f9fe4b926078698 /svtools
parent470752f50c146b449b1c9bdccc36ed031535663c (diff)
replace misc double checked locking patterns
... with thread safe local statics Change-Id: Ie3c8023776a388846b989f00a0be185273c0d5da Reviewed-on: https://gerrit.libreoffice.org/38907 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/config/helpopt.cxx13
-rw-r--r--svtools/source/config/menuoptions.cxx21
-rw-r--r--svtools/source/config/printoptions.cxx21
3 files changed, 8 insertions, 47 deletions
diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx
index 381d67f7f0a4..bc1ac4d014c1 100644
--- a/svtools/source/config/helpopt.cxx
+++ b/svtools/source/config/helpopt.cxx
@@ -98,18 +98,9 @@ Sequence< OUString > const & SvtHelpOptions_Impl::GetPropertyNames()
::osl::Mutex & SvtHelpOptions_Impl::getInitMutex()
{
- static ::osl::Mutex *pMutex = nullptr;
+ static ::osl::Mutex ourMutex;
- if( ! pMutex )
- {
- ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
- if( ! pMutex )
- {
- static ::osl::Mutex mutex;
- pMutex = &mutex;
- }
- }
- return *pMutex;
+ return ourMutex;
}
SvtHelpOptions_Impl::SvtHelpOptions_Impl()
diff --git a/svtools/source/config/menuoptions.cxx b/svtools/source/config/menuoptions.cxx
index cc8b64b760bc..8bec940d4000 100644
--- a/svtools/source/config/menuoptions.cxx
+++ b/svtools/source/config/menuoptions.cxx
@@ -410,24 +410,9 @@ void SvtMenuOptions::SetContextMenuShortcuts(TriState eState)
Mutex& SvtMenuOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = nullptr;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == nullptr )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of our class will be faster than these!
- if( pMutex == nullptr )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ static Mutex ourMutex;
+
+ return ourMutex;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/printoptions.cxx b/svtools/source/config/printoptions.cxx
index be4a73644d4d..05ac6875d4a4 100644
--- a/svtools/source/config/printoptions.cxx
+++ b/svtools/source/config/printoptions.cxx
@@ -508,24 +508,9 @@ SvtBasePrintOptions::~SvtBasePrintOptions()
Mutex& SvtBasePrintOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = nullptr;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == nullptr )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of our class will be faster than these!
- if( pMutex == nullptr )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ static Mutex ourMutex;
+
+ return ourMutex;
}
bool SvtBasePrintOptions::IsReduceTransparency() const