forms/source/component/EventThread.cxx | 12 +++++++----- forms/source/component/EventThread.hxx | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-)
New commits: commit 1ce02008ae8b61a6a489e65bd32b5e8bdc47e99e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Feb 24 15:06:06 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Feb 27 14:10:03 2023 +0000 osl::Mutex->std::mutex in frm::OComponentEventThread Change-Id: I419a96fce0d5dbdd438dda32217ced39ba598446 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147864 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/forms/source/component/EventThread.cxx b/forms/source/component/EventThread.cxx index 0b38e33f7a4d..2d5336fe384b 100644 --- a/forms/source/component/EventThread.cxx +++ b/forms/source/component/EventThread.cxx @@ -79,7 +79,7 @@ void OComponentEventThread::disposing( const EventObject& evt ) if( evt.Source != static_cast<XWeak*>(m_xComp.get()) ) return; - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); // Remove EventListener Reference<XEventListener> xEvtLstnr = static_cast<XEventListener*>(this); @@ -107,7 +107,7 @@ void OComponentEventThread::addEvent( std::unique_ptr<EventObject> _pEvt, const Reference<XControl>& rControl, bool bFlag ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); // Put data into the queue m_aEvents.push_back( std::move( _pEvt ) ); @@ -140,7 +140,7 @@ void OComponentEventThread::run() do { - ::osl::MutexGuard aGuard(m_aMutex); + std::unique_lock aGuard(m_aMutex); while( !m_aEvents.empty() ) { @@ -160,7 +160,7 @@ void OComponentEventThread::run() m_aFlags.erase( firstFlag ); { - MutexRelease aReleaseOnce(m_aMutex); + aGuard.unlock(); // Because a queryHardRef can throw an Exception, it should not be called when // the mutex is locked. Reference<XControl> xControl; @@ -170,6 +170,7 @@ void OComponentEventThread::run() if( xComp.is() ) processEvent( xComp.get(), pEvt.get(), xControl, bFlag ); + aGuard.lock(); } } @@ -181,9 +182,10 @@ void OComponentEventThread::run() // Reset waiting condition m_aCond.reset(); { - MutexRelease aReleaseOnce(m_aMutex); + aGuard.unlock(); // And wait ... if, in the meantime, an Event came in after all m_aCond.wait(); + aGuard.lock(); } } while( true ); diff --git a/forms/source/component/EventThread.hxx b/forms/source/component/EventThread.hxx index 20aff73113db..df7b33ee134f 100644 --- a/forms/source/component/EventThread.hxx +++ b/forms/source/component/EventThread.hxx @@ -22,6 +22,7 @@ #include <sal/config.h> #include <memory> +#include <mutex> #include <vector> #include <com/sun/star/lang/XEventListener.hpp> @@ -50,7 +51,7 @@ class OComponentEventThread typedef std::vector<std::unique_ptr<css::lang::EventObject>> ThreadEvents; typedef std::vector< css::uno::Reference< css::uno::XAdapter> > ThreadObjects; - ::osl::Mutex m_aMutex; + std::mutex m_aMutex; ::osl::Condition m_aCond; // Queue filled? ThreadEvents m_aEvents; // EventQueue ThreadObjects m_aControls; // Control for Submit