diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-12-23 17:27:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-27 17:05:02 +0100 |
commit | 03c7cd9bbe3d46bb13a5cf1ad72ba0eaf702747e (patch) | |
tree | 449f965931941b6e4b238ac54238cd0e6f57b09d /ucb | |
parent | c350c74dbd7783a5efd5ba04e937001670101243 (diff) |
osl::Mutex->std::mutex in SerfLockStore
Change-Id: I931e20b4b604ebd6fac83006deeabaa5939e8c7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127587
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav-curl/SerfLockStore.cxx | 28 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/SerfLockStore.hxx | 7 |
2 files changed, 21 insertions, 14 deletions
diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx index 932fb5262411..ec47278b843b 100644 --- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx +++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx @@ -89,9 +89,9 @@ SerfLockStore::SerfLockStore() SerfLockStore::~SerfLockStore() { - osl::ResettableMutexGuard aGuard(m_aMutex); + std::unique_lock aGuard(m_aMutex); stopTicker(aGuard); - aGuard.reset(); // actually no threads should even try to access members now + aGuard.lock(); // actually no threads should even try to access members now m_bFinishing = true; // release active locks, if any. @@ -106,7 +106,7 @@ SerfLockStore::~SerfLockStore() void SerfLockStore::startTicker() { - osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( !m_pTickerThread.is() ) { @@ -116,7 +116,7 @@ void SerfLockStore::startTicker() } -void SerfLockStore::stopTicker(osl::ClearableMutexGuard & rGuard) +void SerfLockStore::stopTicker(std::unique_lock<std::mutex> & rGuard) { rtl::Reference<TickerThread> pTickerThread; @@ -128,7 +128,7 @@ void SerfLockStore::stopTicker(osl::ClearableMutexGuard & rGuard) m_pTickerThread.clear(); } - rGuard.clear(); + rGuard.unlock(); if (pTickerThread.is() && pTickerThread->getIdentifier() != osl::Thread::getCurrentIdentifier()) { @@ -141,7 +141,7 @@ SerfLockStore::getLockTokenForURI(OUString const& rURI, css::ucb::Lock const*con { assert(rURI.startsWith("http://") || rURI.startsWith("https://")); - osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); auto const it(m_aLockInfoMap.find(rURI)); @@ -179,7 +179,7 @@ void SerfLockStore::addLock( const OUString& rURI, { assert(rURI.startsWith("http://") || rURI.startsWith("https://")); - osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); m_aLockInfoMap[ rURI ] = LockInfo(sToken, rLock, xSession, nLastChanceToSendRefreshRequest); @@ -190,9 +190,16 @@ void SerfLockStore::addLock( const OUString& rURI, void SerfLockStore::removeLock(const OUString& rURI) { + std::unique_lock aGuard( m_aMutex ); + + removeLockImpl(rURI); +} + +void SerfLockStore::removeLockImpl(const OUString& rURI) +{ assert(rURI.startsWith("http://") || rURI.startsWith("https://")); - osl::ClearableMutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); m_aLockInfoMap.erase(rURI); @@ -200,10 +207,9 @@ void SerfLockStore::removeLock(const OUString& rURI) stopTicker(aGuard); } - void SerfLockStore::refreshLocks() { - osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); ::std::vector<OUString> authFailedLocks; @@ -244,7 +250,7 @@ void SerfLockStore::refreshLocks() for (auto const& rLock : authFailedLocks) { - removeLock(rLock); + removeLockImpl(rLock); } } diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx index 7e0757004c41..c3c645b66f2c 100644 --- a/ucb/source/ucp/webdav-curl/SerfLockStore.hxx +++ b/ucb/source/ucp/webdav-curl/SerfLockStore.hxx @@ -21,7 +21,7 @@ #pragma once #include <map> -#include <osl/mutex.hxx> +#include <mutex> #include <rtl/ref.hxx> #include <rtl/ustring.hxx> #include <com/sun/star/ucb/Lock.hpp> @@ -58,7 +58,7 @@ typedef std::map< OUString, LockInfo > LockInfoMap; class SerfLockStore { - osl::Mutex m_aMutex; + std::mutex m_aMutex; rtl::Reference< TickerThread > m_pTickerThread; bool m_bFinishing; LockInfoMap m_aLockInfoMap; @@ -82,8 +82,9 @@ public: void refreshLocks(); private: + void removeLockImpl(const OUString& rURI); void startTicker(); - void stopTicker(osl::ClearableMutexGuard & rGuard); + void stopTicker(std::unique_lock<std::mutex> & rGuard); }; } // namespace http_dav_ucp |