From 1576ef8532cf2cea2da361db9c5707f1994e65e2 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 23 Dec 2021 18:40:44 +0200 Subject: osl::Mutex->std::mutex in SvtCommandOptions Change-Id: I80eaba645351e2f3a3c67586fdced3325608633e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127413 Tested-by: Jenkins Reviewed-by: Noel Grandin --- unotools/source/config/cmdoptions.cxx | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'unotools') diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx index d9e061224a4a..1408f22c2480 100644 --- a/unotools/source/config/cmdoptions.cxx +++ b/unotools/source/config/cmdoptions.cxx @@ -84,6 +84,12 @@ class SvtCmdOptions CommandHashMap m_aCommandHashMap; }; +std::mutex& GetOwnStaticMutex() +{ + static std::mutex theCommandOptionsMutex; + return theCommandOptionsMutex; +} + } typedef ::std::vector< css::uno::WeakReference< css::frame::XFrame > > SvtFrameVector; @@ -185,7 +191,7 @@ SvtCommandOptions_Impl::~SvtCommandOptions_Impl() void SvtCommandOptions_Impl::Notify( const Sequence< OUString >& ) { - MutexGuard aGuard( SvtCommandOptions::GetOwnStaticMutex() ); + std::unique_lock aGuard( GetOwnStaticMutex() ); Sequence< OUString > lNames = impl_GetPropertyNames (); Sequence< Any > lValues = GetProperties ( lNames ); @@ -296,13 +302,14 @@ std::weak_ptr g_pCommandOptions; SvtCommandOptions::SvtCommandOptions() { // Global access, must be guarded (multithreading!). - MutexGuard aGuard( GetOwnStaticMutex() ); + std::unique_lock aGuard( GetOwnStaticMutex() ); m_pImpl = g_pCommandOptions.lock(); if( !m_pImpl ) { m_pImpl = std::make_shared(); g_pCommandOptions = m_pImpl; + aGuard.unlock(); // because holdConfigItem will call this constructor ItemHolder1::holdConfigItem(EItem::CmdOptions); } } @@ -310,7 +317,7 @@ SvtCommandOptions::SvtCommandOptions() SvtCommandOptions::~SvtCommandOptions() { // Global access, must be guarded (multithreading!) - MutexGuard aGuard( GetOwnStaticMutex() ); + std::unique_lock aGuard( GetOwnStaticMutex() ); m_pImpl.reset(); } @@ -319,7 +326,7 @@ SvtCommandOptions::~SvtCommandOptions() bool SvtCommandOptions::HasEntries( CmdOption eOption ) const { - MutexGuard aGuard( GetOwnStaticMutex() ); + std::unique_lock aGuard( GetOwnStaticMutex() ); return m_pImpl->HasEntries( eOption ); } @@ -327,7 +334,7 @@ bool SvtCommandOptions::HasEntries( CmdOption eOption ) const bool SvtCommandOptions::Lookup( CmdOption eCmdOption, const OUString& aCommandURL ) const { - MutexGuard aGuard( GetOwnStaticMutex() ); + std::unique_lock aGuard( GetOwnStaticMutex() ); return m_pImpl->Lookup( eCmdOption, aCommandURL ); } @@ -335,16 +342,8 @@ bool SvtCommandOptions::Lookup( CmdOption eCmdOption, const OUString& aCommandUR void SvtCommandOptions::EstablishFrameCallback(const css::uno::Reference< css::frame::XFrame >& xFrame) { - MutexGuard aGuard( GetOwnStaticMutex() ); + std::unique_lock aGuard( GetOwnStaticMutex() ); m_pImpl->EstablishFrameCallback(xFrame); } -// private method - -Mutex& SvtCommandOptions::GetOwnStaticMutex() -{ - static osl::Mutex theCommandOptionsMutex; - return theCommandOptionsMutex; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit