diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-05-08 21:39:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-17 13:22:40 +0200 |
commit | ef3c759357cb3dbe4fee46afd24105a1c2e24126 (patch) | |
tree | ec703d8e87e30448d8a162c36eecb804a49abf5b /ucb | |
parent | 42eeb373978deb660f38707babfc9d5af9da5cd9 (diff) |
osl::Mutex->std::mutex in HierarchyResultSetDataSupplier
Change-Id: I61bcbc85fbbae469c5463a69dc835b7d1ac0575c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134086
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx | 38 | ||||
-rw-r--r-- | ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx | 10 |
2 files changed, 32 insertions, 16 deletions
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx index 77747883bcbb..1a2f29f6b30c 100644 --- a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx +++ b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx @@ -60,8 +60,14 @@ HierarchyResultSetDataSupplier::~HierarchyResultSetDataSupplier() OUString HierarchyResultSetDataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); + return queryContentIdentifierStringImpl(aGuard, nIndex); +} +OUString HierarchyResultSetDataSupplier::queryContentIdentifierStringImpl( + std::unique_lock<std::mutex>& rGuard, + sal_uInt32 nIndex ) +{ if ( nIndex < m_aResults.size() ) { OUString aId = m_aResults[ nIndex ]->aId; @@ -72,7 +78,7 @@ OUString HierarchyResultSetDataSupplier::queryContentIdentifierString( } } - if ( getResult( nIndex ) ) + if ( getResultImpl( rGuard, nIndex ) ) { OUString aId = m_xContent->getIdentifier()->getContentIdentifier(); @@ -93,7 +99,7 @@ OUString HierarchyResultSetDataSupplier::queryContentIdentifierString( uno::Reference< ucb::XContentIdentifier > HierarchyResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( nIndex < m_aResults.size() ) { @@ -106,7 +112,7 @@ HierarchyResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) } } - OUString aId = queryContentIdentifierString( nIndex ); + OUString aId = queryContentIdentifierStringImpl( aGuard, nIndex ); if ( !aId.isEmpty() ) { uno::Reference< ucb::XContentIdentifier > xId @@ -122,7 +128,7 @@ HierarchyResultSetDataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) uno::Reference< ucb::XContent > HierarchyResultSetDataSupplier::queryContent( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( nIndex < m_aResults.size() ) { @@ -158,8 +164,12 @@ HierarchyResultSetDataSupplier::queryContent( sal_uInt32 nIndex ) // virtual bool HierarchyResultSetDataSupplier::getResult( sal_uInt32 nIndex ) { - osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); + return getResultImpl(aGuard, nIndex); +} +bool HierarchyResultSetDataSupplier::getResultImpl( std::unique_lock<std::mutex>& rGuard, sal_uInt32 nIndex ) +{ if ( m_aResults.size() > nIndex ) { // Result already present. @@ -201,7 +211,7 @@ bool HierarchyResultSetDataSupplier::getResult( sal_uInt32 nIndex ) if ( xResultSet.is() ) { // Callbacks follow! - aGuard.clear(); + rGuard.unlock(); if ( nOldCount < m_aResults.size() ) xResultSet->rowCountChanged( @@ -209,6 +219,8 @@ bool HierarchyResultSetDataSupplier::getResult( sal_uInt32 nIndex ) if ( m_bCountFinal ) xResultSet->rowCountFinal(); + + rGuard.lock(); } return bFound; @@ -218,7 +230,7 @@ bool HierarchyResultSetDataSupplier::getResult( sal_uInt32 nIndex ) // virtual sal_uInt32 HierarchyResultSetDataSupplier::totalCount() { - osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bCountFinal ) return m_aResults.size(); @@ -238,7 +250,7 @@ sal_uInt32 HierarchyResultSetDataSupplier::totalCount() if ( xResultSet.is() ) { // Callbacks follow! - aGuard.clear(); + aGuard.unlock(); if ( nOldCount < m_aResults.size() ) xResultSet->rowCountChanged( @@ -269,7 +281,7 @@ bool HierarchyResultSetDataSupplier::isCountFinal() uno::Reference< sdbc::XRow > HierarchyResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( nIndex < m_aResults.size() ) { @@ -282,7 +294,7 @@ HierarchyResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex ) } } - if ( getResult( nIndex ) ) + if ( getResultImpl( aGuard, nIndex ) ) { HierarchyContentProperties aData( m_aResults[ nIndex ]->aData ); @@ -294,7 +306,7 @@ HierarchyResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex ) aData, static_cast< HierarchyContentProvider * >( m_xContent->getProvider().get() ), - queryContentIdentifierString( nIndex ) ); + queryContentIdentifierStringImpl( aGuard, nIndex ) ); m_aResults[ nIndex ]->xRow = xRow; return xRow; } @@ -306,7 +318,7 @@ HierarchyResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex ) // virtual void HierarchyResultSetDataSupplier::releasePropertyValues( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( nIndex < m_aResults.size() ) m_aResults[ nIndex ]->xRow.clear(); diff --git a/ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx b/ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx index d1cfdb1446c0..8bad51dc0d5a 100644 --- a/ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx +++ b/ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx @@ -21,6 +21,7 @@ #include <rtl/ref.hxx> #include <ucbhelper/resultset.hxx> +#include <mutex> #include <vector> #include "hierarchydata.hxx" @@ -42,13 +43,13 @@ public: sal_Int32 nOpenMode ); virtual ~HierarchyResultSetDataSupplier() override; - virtual OUString queryContentIdentifierString( sal_uInt32 nIndex ) override; + virtual OUString queryContentIdentifierString( sal_uInt32 nIndex ) final override; virtual css::uno::Reference< css::ucb::XContentIdentifier > queryContentIdentifier( sal_uInt32 nIndex ) override; virtual css::uno::Reference< css::ucb::XContent > queryContent( sal_uInt32 nIndex ) override; - virtual bool getResult( sal_uInt32 nIndex ) override; + virtual bool getResult( sal_uInt32 nIndex ) final override; virtual sal_uInt32 totalCount() override; virtual sal_uInt32 currentCount() override; @@ -62,6 +63,9 @@ public: virtual void validate() override; private: + OUString queryContentIdentifierStringImpl( std::unique_lock<std::mutex>&, sal_uInt32 nIndex ); + bool getResultImpl( std::unique_lock<std::mutex>&, sal_uInt32 nIndex ); + struct ResultListEntry { OUString aId; @@ -73,7 +77,7 @@ private: explicit ResultListEntry( const HierarchyEntryData& rEntry ) : aData( rEntry ) {} }; typedef std::vector< std::unique_ptr<ResultListEntry> > ResultList; - osl::Mutex m_aMutex; + std::mutex m_aMutex; ResultList m_aResults; rtl::Reference< HierarchyContent > m_xContent; css::uno::Reference< css::uno::XComponentContext > m_xContext; |