avmedia/source/win/window.cxx         |   87 ++++++++++++++--------------------
 avmedia/source/win/window.hxx         |   13 +++--
 connectivity/source/parse/sqlbison.y  |    3 -
 connectivity/source/parse/sqlnode.cxx |   10 +--
 include/connectivity/sqlparse.hxx     |    2 
 5 files changed, 53 insertions(+), 62 deletions(-)

New commits:
commit 770580ba8e9546aa7b960c8b622b936ba6cf9d37
Author:     Noel Grandin <noelgran...@collabora.co.uk>
AuthorDate: Fri Mar 10 15:45:51 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Mar 11 05:54:26 2023 +0000

    osl::Mutex->std::mutex in avmedia::win::Window
    
    Change-Id: I4e6e7fd03c4aa7847edbc48bccac88ec361c8237
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148637
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx
index 4f4ef47456e6..2f453347f7cd 100644
--- a/avmedia/source/win/window.cxx
+++ b/avmedia/source/win/window.cxx
@@ -98,7 +98,6 @@ static WNDCLASSW* lcl_getWndClass()
 }
 
 Window::Window( Player& rPlayer ) :
-    maListeners( maMutex ),
     meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
     mrPlayer( rPlayer ),
     mnFrameWnd( nullptr ),
@@ -349,62 +348,74 @@ void SAL_CALL Window::setFocus(  )
 
 void SAL_CALL Window::addWindowListener( const uno::Reference< 
awt::XWindowListener >& xListener )
 {
-    maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maWindowListeners.addInterface( g, xListener );
 }
 
 void SAL_CALL Window::removeWindowListener( const uno::Reference< 
awt::XWindowListener >& xListener )
 {
-    maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maWindowListeners.removeInterface( g, xListener );
 }
 
 void SAL_CALL Window::addFocusListener( const uno::Reference< 
awt::XFocusListener >& xListener )
 {
-    maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maFocusListeners.addInterface( g, xListener );
 }
 
 void SAL_CALL Window::removeFocusListener( const uno::Reference< 
awt::XFocusListener >& xListener )
 {
-    maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maFocusListeners.removeInterface( g, xListener );
 }
 
 void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener 
>& xListener )
 {
-    maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maKeyListeners.addInterface( g, xListener );
 }
 
 void SAL_CALL Window::removeKeyListener( const uno::Reference< 
awt::XKeyListener >& xListener )
 {
-    maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maKeyListeners.removeInterface( g, xListener );
 }
 
 void SAL_CALL Window::addMouseListener( const uno::Reference< 
awt::XMouseListener >& xListener )
 {
-    maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maMouseListeners.addInterface( g, xListener );
 }
 
 void SAL_CALL Window::removeMouseListener( const uno::Reference< 
awt::XMouseListener >& xListener )
 {
-    maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maMouseListeners.removeInterface( g, xListener );
 }
 
 void SAL_CALL Window::addMouseMotionListener( const uno::Reference< 
awt::XMouseMotionListener >& xListener )
 {
-    maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maMouseMotionListeners.addInterface( g, xListener );
 }
 
 void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< 
awt::XMouseMotionListener >& xListener )
 {
-    maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maMouseMotionListeners.removeInterface( g, xListener );
 }
 
 void SAL_CALL Window::addPaintListener( const uno::Reference< 
awt::XPaintListener >& xListener )
 {
-    maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maPaintListeners.addInterface( g, xListener );
 }
 
 void SAL_CALL Window::removePaintListener( const uno::Reference< 
awt::XPaintListener >& xListener )
 {
-    maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maPaintListeners.removeInterface( g, xListener );
 }
 
 void SAL_CALL Window::dispose(  )
@@ -413,64 +424,38 @@ void SAL_CALL Window::dispose(  )
 
 void SAL_CALL Window::addEventListener( const uno::Reference< 
lang::XEventListener >& xListener )
 {
-    maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maEventListeners.addInterface( g, xListener );
 }
 
 void SAL_CALL Window::removeEventListener( const uno::Reference< 
lang::XEventListener >& xListener )
 {
-    maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), 
xListener );
+    std::unique_lock g(maMutex);
+    maEventListeners.removeInterface( g, xListener );
 }
 
 void Window::fireMousePressedEvent( const css::awt::MouseEvent& rEvt )
 {
-    comphelper::OInterfaceContainerHelper2* pContainer = 
maListeners.getContainer( cppu::UnoType<awt::XMouseListener>::get());
-
-    if( pContainer )
-    {
-        comphelper::OInterfaceIteratorHelper2 aIter( *pContainer );
-
-        while( aIter.hasMoreElements() )
-            static_cast< awt::XMouseListener* >( aIter.next() )->mousePressed( 
rEvt );
-    }
+    std::unique_lock g(maMutex);
+    maMouseListeners.notifyEach(g, &awt::XMouseListener::mousePressed, rEvt);
 }
 
 void Window::fireMouseReleasedEvent( const css::awt::MouseEvent& rEvt )
 {
-    comphelper::OInterfaceContainerHelper2* pContainer = 
maListeners.getContainer( cppu::UnoType<awt::XMouseListener>::get());
-
-    if( pContainer )
-    {
-        comphelper::OInterfaceIteratorHelper2 aIter( *pContainer );
-
-        while( aIter.hasMoreElements() )
-            static_cast< awt::XMouseListener* >( aIter.next() 
)->mouseReleased( rEvt );
-    }
+    std::unique_lock g(maMutex);
+    maMouseListeners.notifyEach(g, &awt::XMouseListener::mouseReleased, rEvt);
 }
 
 void Window::fireMouseMovedEvent( const css::awt::MouseEvent& rEvt )
 {
-    comphelper::OInterfaceContainerHelper2* pContainer = 
maListeners.getContainer( cppu::UnoType<awt::XMouseMotionListener>::get());
-
-    if( pContainer )
-    {
-        comphelper::OInterfaceIteratorHelper2 aIter( *pContainer );
-
-        while( aIter.hasMoreElements() )
-            static_cast< awt::XMouseMotionListener* >( aIter.next() 
)->mouseMoved( rEvt );
-    }
+    std::unique_lock g(maMutex);
+    maMouseMotionListeners.notifyEach(g, 
&awt::XMouseMotionListener::mouseMoved, rEvt);
 }
 
 void Window::fireSetFocusEvent( const css::awt::FocusEvent& rEvt )
 {
-    comphelper::OInterfaceContainerHelper2* pContainer = 
maListeners.getContainer( cppu::UnoType<awt::XFocusListener>::get());
-
-    if( pContainer )
-    {
-        comphelper::OInterfaceIteratorHelper2 aIter( *pContainer );
-
-        while( aIter.hasMoreElements() )
-            static_cast< awt::XFocusListener* >( aIter.next() )->focusGained( 
rEvt );
-    }
+    std::unique_lock g(maMutex);
+    maFocusListeners.notifyEach(g, &awt::XFocusListener::focusGained, rEvt);
 }
 
 OUString SAL_CALL Window::getImplementationName(  )
diff --git a/avmedia/source/win/window.hxx b/avmedia/source/win/window.hxx
index 39d5aec626c4..0ab691ffbb82 100644
--- a/avmedia/source/win/window.hxx
+++ b/avmedia/source/win/window.hxx
@@ -25,7 +25,8 @@
 
 #include "wincommon.hxx"
 #include <cppuhelper/implbase.hxx>
-#include <comphelper/multicontainer2.hxx>
+#include <comphelper/interfacecontainer4.hxx>
+#include <mutex>
 
 #include <com/sun/star/media/XPlayerWindow.hpp>
 
@@ -95,8 +96,14 @@ public:
 
 private:
 
-    ::osl::Mutex                                maMutex;
-    comphelper::OMultiTypeInterfaceContainerHelper2  maListeners;
+    std::mutex                                       maMutex;
+    comphelper::OInterfaceContainerHelper4<css::awt::XWindowListener>  
maWindowListeners;
+    comphelper::OInterfaceContainerHelper4<css::awt::XFocusListener>  
maFocusListeners;
+    comphelper::OInterfaceContainerHelper4<css::awt::XKeyListener>  
maKeyListeners;
+    comphelper::OInterfaceContainerHelper4<css::awt::XMouseListener>  
maMouseListeners;
+    comphelper::OInterfaceContainerHelper4<css::awt::XMouseMotionListener>  
maMouseMotionListeners;
+    comphelper::OInterfaceContainerHelper4<css::awt::XPaintListener>  
maPaintListeners;
+    comphelper::OInterfaceContainerHelper4<css::lang::XEventListener>  
maEventListeners;
     css::media::ZoomLevel                       meZoomLevel;
     Player&                                     mrPlayer;
     HWND                                        mnFrameWnd;
commit b6977dad4535532d9bd897282f52806885862c83
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Mar 10 16:01:15 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Mar 11 05:54:16 2023 +0000

    osl::Mutex->std::mutex in OSQLParser
    
    Change-Id: Ibc56fee796914a6dd39970f7a7879d5b5b2c219f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148660
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/connectivity/source/parse/sqlbison.y 
b/connectivity/source/parse/sqlbison.y
index 6db0da9a4180..cbad86149fc2 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -4502,7 +4502,6 @@ void setParser(OSQLParser* _pParser)
 
 void OSQLParser::setParseTree(OSQLParseNode* pNewParseTree)
 {
-       ::osl::MutexGuard aGuard(getMutex());
        m_pParseTree.reset(pNewParseTree);
 }
 
@@ -4574,7 +4573,7 @@ std::unique_ptr<OSQLParseNode> 
OSQLParser::parseTree(OUString& rErrorMessage,
 
 
        // Guard the parsing
-       ::osl::MutexGuard aGuard(getMutex());
+       std::unique_lock aGuard(getMutex());
        // must be reset
        setParser(this);
 
diff --git a/connectivity/source/parse/sqlnode.cxx 
b/connectivity/source/parse/sqlnode.cxx
index fecb00cdc9b2..4f213bf4f902 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -1141,9 +1141,9 @@ OUString OSQLParser::stringToDouble(const OUString& 
_rValue,sal_Int16 _nScale)
 }
 
 
-::osl::Mutex& OSQLParser::getMutex()
+std::mutex& OSQLParser::getMutex()
 {
-    static ::osl::Mutex aMutex;
+    static std::mutex aMutex;
     return aMutex;
 }
 
@@ -1154,7 +1154,7 @@ std::unique_ptr<OSQLParseNode> 
OSQLParser::predicateTree(OUString& rErrorMessage
                                          bool bUseRealName)
 {
     // Guard the parsing
-    ::osl::MutexGuard aGuard(getMutex());
+    std::unique_lock aGuard(getMutex());
     // must be reset
     setParser(this);
 
@@ -1322,7 +1322,7 @@ OSQLParser::OSQLParser(css::uno::Reference< 
css::uno::XComponentContext > xConte
 #endif
 #endif
 
-    ::osl::MutexGuard aGuard(getMutex());
+    std::unique_lock aGuard(getMutex());
     // Do we have to initialize the data?
     if (s_nRefCount == 0)
     {
@@ -1472,7 +1472,7 @@ OSQLParser::OSQLParser(css::uno::Reference< 
css::uno::XComponentContext > xConte
 
 OSQLParser::~OSQLParser()
 {
-    ::osl::MutexGuard aGuard(getMutex());
+    std::unique_lock aGuard(getMutex());
     OSL_ENSURE(s_nRefCount > 0, "OSQLParser::~OSQLParser() : suspicious call : 
has a refcount of 0 !");
     if (!--s_nRefCount)
     {
diff --git a/include/connectivity/sqlparse.hxx 
b/include/connectivity/sqlparse.hxx
index d3eedd484137..c3314c470c6b 100644
--- a/include/connectivity/sqlparse.hxx
+++ b/include/connectivity/sqlparse.hxx
@@ -150,7 +150,7 @@ namespace connectivity
         OSQLParseNode*  buildNode_STR_NUM(OSQLParseNode*& pLiteral);
         OSQLParseNode*  buildNode_Date(const double& fValue, sal_Int32 nType);
 
-        static ::osl::Mutex& getMutex();
+        static std::mutex& getMutex();
 
     public:
         // if NULL, a default context will be used

Reply via email to