summaryrefslogtreecommitdiff
path: root/unotools/source/config/cmdoptions.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-04-03 21:34:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-04-03 21:43:01 +0100
commitf183d3a500626354508993d453e265da9614df45 (patch)
tree9ce9e5dc75b002d1901f905083c66eeaaa3799ff /unotools/source/config/cmdoptions.cxx
parent41d271db85a1adec8591f08b969695c0f7885356 (diff)
use rtl::Static where double-locked pattern used
Diffstat (limited to 'unotools/source/config/cmdoptions.cxx')
-rw-r--r--unotools/source/config/cmdoptions.cxx25
1 files changed, 7 insertions, 18 deletions
diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx
index b17771cb4369..c110148c069f 100644
--- a/unotools/source/config/cmdoptions.cxx
+++ b/unotools/source/config/cmdoptions.cxx
@@ -42,6 +42,7 @@
#include <cppuhelper/weakref.hxx>
#include <tools/urlobj.hxx>
#include <rtl/ustrbuf.hxx>
+#include <rtl/instance.hxx>
#include <itemholder1.hxx>
@@ -593,29 +594,17 @@ void SvtCommandOptions::EstablisFrameCallback(const ::com::sun::star::uno::Refer
m_pDataContainer->EstablisFrameCallback(xFrame);
}
+namespace
+{
+ class theCommandOptionsMutex : public rtl::Static<osl::Mutex, theCommandOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtCommandOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... 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 ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // 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;
+ return theCommandOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */