diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-20 12:51:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-20 17:16:36 +0200 |
commit | 37ce4266d66323f158b20b9e0ec0388209f5e9f6 (patch) | |
tree | 5664e640d2035f39a890e138d383b32d7b754f04 /ucb | |
parent | ce39195e533336ce1482e2be6b1bec2b7f992125 (diff) |
osl::Mutex->std::mutex in DataSupplier
Change-Id: I60fccc5d419d42571e768bd4b4ec5fe14d709896
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134676
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/package/pkgdatasupplier.cxx | 43 | ||||
-rw-r--r-- | ucb/source/ucp/package/pkgdatasupplier.hxx | 7 |
2 files changed, 35 insertions, 15 deletions
diff --git a/ucb/source/ucp/package/pkgdatasupplier.cxx b/ucb/source/ucp/package/pkgdatasupplier.cxx index a1337c2646ca..242c94e14b07 100644 --- a/ucb/source/ucp/package/pkgdatasupplier.cxx +++ b/ucb/source/ucp/package/pkgdatasupplier.cxx @@ -61,8 +61,12 @@ DataSupplier::~DataSupplier() // virtual OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); + return queryContentIdentifierStringImpl(aGuard, nIndex); +} +OUString DataSupplier::queryContentIdentifierStringImpl( std::unique_lock<std::mutex>& rGuard, sal_uInt32 nIndex ) +{ if ( nIndex < m_aResults.size() ) { OUString aId = m_aResults[ nIndex ].aURL; @@ -73,7 +77,7 @@ OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) } } - if ( getResult( nIndex ) ) + if ( getResultImpl( rGuard, nIndex ) ) { // Note: getResult fills m_aResults[ nIndex ].aURL. return m_aResults[ nIndex ].aURL; @@ -86,8 +90,13 @@ OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) uno::Reference< ucb::XContentIdentifier > DataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); + return queryContentIdentifierImpl(aGuard, nIndex); +} +uno::Reference< ucb::XContentIdentifier > +DataSupplier::queryContentIdentifierImpl( std::unique_lock<std::mutex>& rGuard, sal_uInt32 nIndex ) +{ if ( nIndex < m_aResults.size() ) { uno::Reference< ucb::XContentIdentifier >& xId @@ -99,7 +108,7 @@ DataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) } } - OUString aId = queryContentIdentifierString( nIndex ); + OUString aId = queryContentIdentifierStringImpl( rGuard, nIndex ); if ( !aId.isEmpty() ) { uno::Reference< ucb::XContentIdentifier > xId @@ -115,7 +124,7 @@ DataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) uno::Reference< ucb::XContent > DataSupplier::queryContent( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( nIndex < m_aResults.size() ) { @@ -129,7 +138,7 @@ uno::Reference< ucb::XContent > DataSupplier::queryContent( } uno::Reference< ucb::XContentIdentifier > xId - = queryContentIdentifier( nIndex ); + = queryContentIdentifierImpl( aGuard, nIndex ); if ( xId.is() ) { try @@ -151,8 +160,12 @@ uno::Reference< ucb::XContent > DataSupplier::queryContent( // virtual bool DataSupplier::getResult( sal_uInt32 nIndex ) { - osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); + return getResultImpl(aGuard, nIndex); +} +bool DataSupplier::getResultImpl( std::unique_lock<std::mutex>& rGuard, sal_uInt32 nIndex ) +{ if ( m_aResults.size() > nIndex ) { // Result already present. @@ -224,7 +237,7 @@ bool DataSupplier::getResult( sal_uInt32 nIndex ) if ( xResultSet.is() ) { // Callbacks follow! - aGuard.clear(); + rGuard.unlock(); if ( nOldCount < m_aResults.size() ) xResultSet->rowCountChanged( @@ -232,6 +245,8 @@ bool DataSupplier::getResult( sal_uInt32 nIndex ) if ( m_bCountFinal ) xResultSet->rowCountFinal(); + + rGuard.lock(); } return bFound; @@ -241,7 +256,7 @@ bool DataSupplier::getResult( sal_uInt32 nIndex ) // virtual sal_uInt32 DataSupplier::totalCount() { - osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( m_bCountFinal ) return m_aResults.size(); @@ -292,7 +307,7 @@ sal_uInt32 DataSupplier::totalCount() if ( xResultSet.is() ) { // Callbacks follow! - aGuard.clear(); + aGuard.unlock(); if ( nOldCount < m_aResults.size() ) xResultSet->rowCountChanged( @@ -323,7 +338,7 @@ bool DataSupplier::isCountFinal() uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( nIndex < m_aResults.size() ) { @@ -335,14 +350,14 @@ uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( } } - if ( getResult( nIndex ) ) + if ( getResultImpl( aGuard, nIndex ) ) { uno::Reference< sdbc::XRow > xRow = Content::getPropertyValues( m_xContext, getResultSet()->getProperties(), static_cast< ContentProvider * >( m_xContent->getProvider().get() ), - queryContentIdentifierString( nIndex ) ); + queryContentIdentifierStringImpl( aGuard, nIndex ) ); m_aResults[ nIndex ].xRow = xRow; return xRow; } @@ -354,7 +369,7 @@ uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( // virtual void DataSupplier::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/package/pkgdatasupplier.hxx b/ucb/source/ucp/package/pkgdatasupplier.hxx index f1ce38fcbb1f..7ac78412c9e9 100644 --- a/ucb/source/ucp/package/pkgdatasupplier.hxx +++ b/ucb/source/ucp/package/pkgdatasupplier.hxx @@ -22,6 +22,7 @@ #include <rtl/ref.hxx> #include <ucbhelper/resultset.hxx> #include <com/sun/star/container/XEnumeration.hpp> +#include <mutex> #include <vector> namespace package_ucp { @@ -58,6 +59,10 @@ public: OUString assembleChildURL( const OUString& aName ); private: + bool getResultImpl( std::unique_lock<std::mutex>&, sal_uInt32 nIndex ); + OUString queryContentIdentifierStringImpl( std::unique_lock<std::mutex>&, sal_uInt32 nIndex ); + css::uno::Reference< css::ucb::XContentIdentifier > queryContentIdentifierImpl( std::unique_lock<std::mutex>&, sal_uInt32 nIndex ); + struct ResultListEntry { OUString aURL; @@ -67,7 +72,7 @@ private: explicit ResultListEntry( const OUString& rURL ) : aURL( rURL ) {} }; - osl::Mutex m_aMutex; + std::mutex m_aMutex; std::vector< ResultListEntry > m_aResults; rtl::Reference< Content > m_xContent; css::uno::Reference< css::uno::XComponentContext > m_xContext; |