ucb/source/ucp/hierarchy/hierarchydatasource.cxx |   23 ++++++++---------------
 ucb/source/ucp/hierarchy/hierarchydatasource.hxx |    8 ++++----
 2 files changed, 12 insertions(+), 19 deletions(-)

New commits:
commit f08c890482952820bf95b04872260c68082ef083
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon May 9 17:48:38 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue May 17 15:40:00 2022 +0200

    osl::Mutex->std::mutex in HierarchyDataSource
    
    HierarchyDataSource::createInstanceWithArguments does
    not need locking since it does not access local state.
    
    Change-Id: Ia29f9a5ca20095d51e4eb168cdc0a080d178f9bd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134087
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx 
b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
index c42ebe2af20e..9c5fa97ae2ee 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
@@ -223,13 +223,13 @@ ucb_HierarchyDataSource_get_implementation(
 // virtual
 void SAL_CALL HierarchyDataSource::dispose()
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
-    if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
+    if ( m_aDisposeEventListeners.getLength(aGuard) )
     {
         lang::EventObject aEvt;
         aEvt.Source = static_cast< lang::XComponent * >( this );
-        m_pDisposeEventListeners->disposeAndClear( aEvt );
+        m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
     }
 }
 
@@ -238,13 +238,9 @@ void SAL_CALL HierarchyDataSource::dispose()
 void SAL_CALL HierarchyDataSource::addEventListener(
                     const uno::Reference< lang::XEventListener > & Listener )
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
-    if ( !m_pDisposeEventListeners )
-        m_pDisposeEventListeners.reset(
-            new comphelper::OInterfaceContainerHelper3<lang::XEventListener>( 
m_aMutex ) );
-
-    m_pDisposeEventListeners->addInterface( Listener );
+    m_aDisposeEventListeners.addInterface( aGuard, Listener );
 }
 
 
@@ -252,10 +248,9 @@ void SAL_CALL HierarchyDataSource::addEventListener(
 void SAL_CALL HierarchyDataSource::removeEventListener(
                     const uno::Reference< lang::XEventListener > & Listener )
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
-    if ( m_pDisposeEventListeners )
-        m_pDisposeEventListeners->removeInterface( Listener );
+    m_aDisposeEventListeners.removeInterface( aGuard, Listener );
 }
 
 
@@ -304,8 +299,6 @@ HierarchyDataSource::createInstanceWithArguments(
                                 const uno::Sequence< uno::Any > & Arguments,
                                 bool bCheckArgs )
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
     // Check service specifier.
     bool bReadOnly  = ServiceSpecifier == READ_SERVICE_NAME;
     bool bReadWrite = !bReadOnly && ServiceSpecifier == READWRITE_SERVICE_NAME;
@@ -420,7 +413,7 @@ HierarchyDataSource::getConfigProvider()
 {
     if ( !m_xConfigProvider.is() )
     {
-        osl::Guard< osl::Mutex > aGuard( m_aMutex );
+        std::unique_lock aGuard( m_aMutex );
         if ( !m_xConfigProvider.is() )
         {
             try
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.hxx 
b/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
index 39dfdb8a424d..b4bff294d22b 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
@@ -19,14 +19,14 @@
 
 #pragma once
 
-#include <osl/mutex.hxx>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <memory>
+#include <mutex>
 #include <string_view>
 
 
@@ -38,10 +38,10 @@ class HierarchyDataSource : public cppu::WeakImplHelper<
                                 css::lang::XComponent,
                                 css::lang::XMultiServiceFactory>
 {
-    osl::Mutex m_aMutex;
+    std::mutex m_aMutex;
     css::uno::Reference< css::uno::XComponentContext >     m_xContext;
     css::uno::Reference< css::lang::XMultiServiceFactory >  m_xConfigProvider;
-    
std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::lang::XEventListener>>
 m_pDisposeEventListeners;
+    comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aDisposeEventListeners;
 
 public:
     explicit HierarchyDataSource( const css::uno::Reference< 
css::uno::XComponentContext > & rxContext );

Reply via email to