diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-02 09:32:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-08 17:30:59 +0000 |
commit | 6f1dd12d808a41ca70d4a33787f1bdff9d44a5ac (patch) | |
tree | 4048cf145e5723c877b53e2144225a0a98dd73c2 /sc | |
parent | f7c03364e24da285ea95cea0cc688a7a120fc163 (diff) |
osl::Mutex->std::mutex in ScExternalRefCache
Change-Id: I3736683d0a7d20694ac2375016c722b4233fdcae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146555
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/externalrefmgr.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 41 |
2 files changed, 26 insertions, 19 deletions
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx index 02a0b28e11f1..238c4a1d0f57 100644 --- a/sc/inc/externalrefmgr.hxx +++ b/sc/inc/externalrefmgr.hxx @@ -34,6 +34,7 @@ #include <tools/solar.h> #include <memory> +#include <mutex> #include <unordered_map> #include <unordered_set> #include <vector> @@ -360,9 +361,10 @@ private: }; typedef std::unordered_map<sal_uInt16, DocItem> DocDataType; DocItem* getDocItem(sal_uInt16 nFileId) const; + DocItem* getDocItem(std::unique_lock<std::mutex>& rGuard, sal_uInt16 nFileId) const; private: - mutable osl::Mutex maMtxDocs; + mutable std::mutex maMtxDocs; mutable DocDataType maDocs; const ScDocument& mrDoc; }; diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 933cc1ad5b11..7ba8527db28a 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -491,7 +491,7 @@ ScExternalRefCache::~ScExternalRefCache() {} const OUString* ScExternalRefCache::getRealTableName(sal_uInt16 nFileId, const OUString& rTabName) const { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); DocDataType::const_iterator itrDoc = maDocs.find(nFileId); if (itrDoc == maDocs.end()) @@ -513,7 +513,7 @@ const OUString* ScExternalRefCache::getRealTableName(sal_uInt16 nFileId, const O const OUString* ScExternalRefCache::getRealRangeName(sal_uInt16 nFileId, const OUString& rRangeName) const { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); DocDataType::const_iterator itrDoc = maDocs.find(nFileId); if (itrDoc == maDocs.end()) @@ -535,7 +535,7 @@ const OUString* ScExternalRefCache::getRealRangeName(sal_uInt16 nFileId, const O ScExternalRefCache::TokenRef ScExternalRefCache::getCellData( sal_uInt16 nFileId, const OUString& rTabName, SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex) { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); DocDataType::const_iterator itrDoc = maDocs.find(nFileId); if (itrDoc == maDocs.end()) @@ -565,7 +565,7 @@ ScExternalRefCache::TokenRef ScExternalRefCache::getCellData( ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData( sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange) { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); DocDataType::iterator itrDoc = maDocs.find(nFileId); if (itrDoc == maDocs.end()) @@ -735,9 +735,9 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData( ScExternalRefCache::TokenArrayRef ScExternalRefCache::getRangeNameTokens(sal_uInt16 nFileId, const OUString& rName) { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); - DocItem* pDoc = getDocItem(nFileId); + DocItem* pDoc = getDocItem(aGuard, nFileId); if (!pDoc) return TokenArrayRef(); @@ -752,9 +752,9 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getRangeNameTokens(sal_uIn void ScExternalRefCache::setRangeNameTokens(sal_uInt16 nFileId, const OUString& rName, TokenArrayRef pArray) { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); - DocItem* pDoc = getDocItem(nFileId); + DocItem* pDoc = getDocItem(aGuard, nFileId); if (!pDoc) return; @@ -766,9 +766,9 @@ void ScExternalRefCache::setRangeNameTokens(sal_uInt16 nFileId, const OUString& bool ScExternalRefCache::isValidRangeName(sal_uInt16 nFileId, const OUString& rName) const { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); - DocItem* pDoc = getDocItem(nFileId); + DocItem* pDoc = getDocItem(aGuard, nFileId); if (!pDoc) return false; @@ -779,9 +779,9 @@ bool ScExternalRefCache::isValidRangeName(sal_uInt16 nFileId, const OUString& rN void ScExternalRefCache::setRangeName(sal_uInt16 nFileId, const OUString& rName) { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); - DocItem* pDoc = getDocItem(nFileId); + DocItem* pDoc = getDocItem(aGuard, nFileId); if (!pDoc) return; @@ -1103,7 +1103,7 @@ SCTAB ScExternalRefCache::getTabSpan( sal_uInt16 nFileId, const OUString& rStart void ScExternalRefCache::getAllNumberFormats(vector<sal_uInt32>& rNumFmts) const { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); using ::std::sort; using ::std::unique; @@ -1170,7 +1170,7 @@ bool ScExternalRefCache::setCacheTableReferenced( sal_uInt16 nFileId, const OUSt void ScExternalRefCache::setAllCacheTableReferencedStati( bool bReferenced ) { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); if (bReferenced) { @@ -1389,14 +1389,14 @@ ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable(sal_uInt16 nF void ScExternalRefCache::clearCache(sal_uInt16 nFileId) { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); maDocs.erase(nFileId); } void ScExternalRefCache::clearCacheTables(sal_uInt16 nFileId) { - osl::MutexGuard aGuard(&maMtxDocs); - DocItem* pDocItem = getDocItem(nFileId); + std::unique_lock aGuard(maMtxDocs); + DocItem* pDocItem = getDocItem(aGuard, nFileId); if (!pDocItem) // This document is not cached at all. return; @@ -1419,7 +1419,12 @@ void ScExternalRefCache::clearCacheTables(sal_uInt16 nFileId) ScExternalRefCache::DocItem* ScExternalRefCache::getDocItem(sal_uInt16 nFileId) const { - osl::MutexGuard aGuard(&maMtxDocs); + std::unique_lock aGuard(maMtxDocs); + return getDocItem(aGuard, nFileId); +} + +ScExternalRefCache::DocItem* ScExternalRefCache::getDocItem(std::unique_lock<std::mutex>& /*rGuard*/, sal_uInt16 nFileId) const +{ using ::std::pair; DocDataType::iterator itrDoc = maDocs.find(nFileId); |