diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-12-23 18:40:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-24 19:50:02 +0100 |
commit | 1576ef8532cf2cea2da361db9c5707f1994e65e2 (patch) | |
tree | 222601e91795b3bcb6738e04d8caf9f1bd74a774 /unotools | |
parent | d94db4056a49fc4fee73173e1ef1c943f8ecc21f (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/config/cmdoptions.cxx | 27 |
1 files changed, 13 insertions, 14 deletions
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<SvtCommandOptions_Impl> 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<SvtCommandOptions_Impl>(); 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: */ |