summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-05-09 18:06:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-10 19:26:20 +0200
commitf75b742997c119ccb081faa7e63ce04b8e88912c (patch)
tree9549b880c07aa575d4264b3aca99c99a2b5491f0 /unotools
parente7d3243d22d6a94930e0cd21721442a2608e03fa (diff)
osl::Mutex->std::mutex in GlobalEventConfig
Change-Id: Id54f9f15547010c9df640e406d36fb09febac4cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134089 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/eventcfg.cxx37
1 files changed, 17 insertions, 20 deletions
diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx
index 197546f5502b..0c0f87ed4624 100644
--- a/unotools/source/config/eventcfg.cxx
+++ b/unotools/source/config/eventcfg.cxx
@@ -81,6 +81,12 @@ static o3tl::enumarray<GlobalEventId, const char*> pEventAsciiNames =
typedef std::unordered_map< OUString, OUString > EventBindingHash;
typedef o3tl::enumarray< GlobalEventId, OUString > SupportedEventsVector;
+static std::mutex& GetOwnStaticMutex()
+{
+ static std::mutex INSTANCE;
+ return INSTANCE;
+}
+
class GlobalEventConfig_Impl : public utl::ConfigItem
{
private:
@@ -150,7 +156,7 @@ OUString const & GlobalEventConfig_Impl::GetEventName( GlobalEventId nIndex ) co
void GlobalEventConfig_Impl::Notify( const Sequence< OUString >& )
{
- MutexGuard aGuard( GlobalEventConfig::GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
initBindingInfo();
}
@@ -295,13 +301,14 @@ sal_Int32 GlobalEventConfig::m_nRefCount = 0;
GlobalEventConfig::GlobalEventConfig()
{
// Global access, must be guarded (multithreading!).
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
// Increase our refcount ...
++m_nRefCount;
// ... and initialize our data container only if it not already exist!
if( m_pImpl == nullptr )
{
m_pImpl = new GlobalEventConfig_Impl;
+ aGuard.unlock();
ItemHolder1::holdConfigItem(EItem::EventConfig);
}
}
@@ -309,7 +316,7 @@ GlobalEventConfig::GlobalEventConfig()
GlobalEventConfig::~GlobalEventConfig()
{
// Global access, must be guarded (multithreading!)
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
// Decrease our refcount.
--m_nRefCount;
// If last instance was deleted ...
@@ -323,52 +330,42 @@ GlobalEventConfig::~GlobalEventConfig()
Reference< container::XNameReplace > SAL_CALL GlobalEventConfig::getEvents()
{
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
Reference< container::XNameReplace > ret(this);
return ret;
}
void SAL_CALL GlobalEventConfig::replaceByName( const OUString& aName, const Any& aElement )
{
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
m_pImpl->replaceByName( aName, aElement );
}
Any SAL_CALL GlobalEventConfig::getByName( const OUString& aName )
{
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
return m_pImpl->getByName( aName );
}
Sequence< OUString > SAL_CALL GlobalEventConfig::getElementNames( )
{
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
return m_pImpl->getElementNames( );
}
sal_Bool SAL_CALL GlobalEventConfig::hasByName( const OUString& aName )
{
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
return m_pImpl->hasByName( aName );
}
Type SAL_CALL GlobalEventConfig::getElementType( )
{
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
return GlobalEventConfig_Impl::getElementType( );
}
sal_Bool SAL_CALL GlobalEventConfig::hasElements( )
{
- MutexGuard aGuard( GetOwnStaticMutex() );
+ std::unique_lock aGuard( GetOwnStaticMutex() );
return m_pImpl->hasElements( );
}
-namespace
-{
- class theGlobalEventConfigMutex : public rtl::Static<osl::Mutex, theGlobalEventConfigMutex>{};
-}
-
-Mutex& GlobalEventConfig::GetOwnStaticMutex()
-{
- return theGlobalEventConfigMutex::get();
-}
-
OUString GlobalEventConfig::GetEventName( GlobalEventId nIndex )
{
if (utl::ConfigManager::IsFuzzing())