From 562a46dbd8a4fa05cff806d7eab164065e30bbe6 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 2 Apr 2011 17:20:24 +0100 Subject: use rtl::Static where double-locked pattern used --- cppuhelper/source/macro_expander.cxx | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'cppuhelper') diff --git a/cppuhelper/source/macro_expander.cxx b/cppuhelper/source/macro_expander.cxx index 4bbebbd21105..3265431c6174 100644 --- a/cppuhelper/source/macro_expander.cxx +++ b/cppuhelper/source/macro_expander.cxx @@ -73,22 +73,30 @@ rtl::OUString expandMacros(rtl::OUString const & text) { namespace { -inline OUString s_impl_name() { return OUSTR(IMPL_NAME); } -static Sequence< OUString > const & s_get_service_names() + +class ImplNames { - static Sequence< OUString > const * s_pnames = 0; - if (! s_pnames) +private: + Sequence m_aNames; +public: + ImplNames() : m_aNames(2) { - MutexGuard guard( Mutex::getGlobalMutex() ); - if (! s_pnames) - { - static Sequence< OUString > s_names( 2 ); - s_names[ 0 ] = OUSTR(SERVICE_NAME_A); - s_names[ 1 ] = OUSTR(SERVICE_NAME_B); - s_pnames = &s_names; - } + m_aNames[0] = OUSTR(SERVICE_NAME_A); + m_aNames[1] = OUSTR(SERVICE_NAME_B); } - return *s_pnames; + const Sequence& getNames() const { return m_aNames; } +}; + +class theImplNames : public rtl::Static {}; + +inline OUString s_impl_name() +{ + return OUSTR(IMPL_NAME); +} + +inline Sequence< OUString > const & s_get_service_names() +{ + return theImplNames::get().getNames(); } typedef ::cppu::WeakComponentImplHelper2< @@ -98,6 +106,7 @@ struct mutex_holder { Mutex m_mutex; }; + class Bootstrap_MacroExpander : public mutex_holder, public t_uno_impl { protected: -- cgit