summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-20 19:59:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-21 09:46:26 +0000
commitd56b6e0904c276e9a9ea63eb226e6324422c21c8 (patch)
treea87b119fcb02fc72cdeed44db537bd348729f79c
parenta61951a3a21c6457334f78f657806c1167dbf339 (diff)
BaseMutex->std::mutex in JobExecutor
Change-Id: I7be392f3023cf188bd6115053dcb1691b32b3e4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147376 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--framework/source/jobs/jobexecutor.cxx94
1 files changed, 46 insertions, 48 deletions
diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx
index f5776fdf283d..158351f19c4e 100644
--- a/framework/source/jobs/jobexecutor.cxx
+++ b/framework/source/jobs/jobexecutor.cxx
@@ -31,8 +31,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/document/XEventListener.hpp>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/configpaths.hxx>
@@ -44,7 +43,7 @@ using namespace framework;
namespace {
-typedef cppu::WeakComponentImplHelper<
+typedef comphelper::WeakComponentImplHelper<
css::lang::XServiceInfo
, css::task::XJobExecutor
, css::container::XContainerListener // => lang.XEventListener
@@ -57,7 +56,7 @@ typedef cppu::WeakComponentImplHelper<
inside the configuration and execute it. Of course it controls the
lifetime of such jobs too.
*/
-class JobExecutor : private cppu::BaseMutex, public Base
+class JobExecutor : public Base
{
private:
@@ -73,7 +72,7 @@ private:
/** helper to allow us listen to the configuration without a cyclic dependency */
css::uno::Reference<css::container::XContainerListener> m_xConfigListener;
- virtual void SAL_CALL disposing() final override;
+ virtual void disposing(std::unique_lock<std::mutex>& rGuard) final override;
public:
@@ -121,8 +120,7 @@ public:
reference to the uno service manager
*/
JobExecutor::JobExecutor( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext )
- : Base (m_aMutex)
- , m_xContext (xContext )
+ : m_xContext (xContext )
, m_aConfig (xContext, "/org.openoffice.Office.Jobs/Events")
{
}
@@ -162,21 +160,19 @@ void JobExecutor::initListeners()
JobExecutor::~JobExecutor()
{
- disposing();
+ std::unique_lock g(m_aMutex);
+ disposing(g);
}
-void JobExecutor::disposing() {
+void JobExecutor::disposing(std::unique_lock<std::mutex>& /*rGuard*/) {
css::uno::Reference<css::container::XContainer> notifier;
css::uno::Reference<css::container::XContainerListener> listener;
- {
- osl::MutexGuard g(rBHelper.rMutex);
- if (m_aConfig.getMode() != ConfigAccess::E_CLOSED) {
- notifier.set(m_aConfig.cfg(), css::uno::UNO_QUERY);
- listener = m_xConfigListener;
- m_aConfig.close();
- }
- m_xConfigListener.clear();
+ if (m_aConfig.getMode() != ConfigAccess::E_CLOSED) {
+ notifier.set(m_aConfig.cfg(), css::uno::UNO_QUERY);
+ listener = m_xConfigListener;
+ m_aConfig.close();
}
+ m_xConfigListener.clear();
if (notifier.is()) {
notifier->removeContainerListener(listener);
}
@@ -195,14 +191,15 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent )
{
SAL_INFO( "fwk", "JobExecutor::trigger()");
- /* SAFE */ {
- osl::MutexGuard g(rBHelper.rMutex);
+ /* SAFE */
+ {
+ std::unique_lock g(m_aMutex);
- // Optimization!
- // Check if the given event name exist inside configuration and reject wrong requests.
- // This optimization suppress using of the cfg api for getting event and job descriptions ...
- if (std::find(m_lEvents.begin(), m_lEvents.end(), sEvent) == m_lEvents.end())
- return;
+ // Optimization!
+ // Check if the given event name exist inside configuration and reject wrong requests.
+ // This optimization suppress using of the cfg api for getting event and job descriptions ...
+ if (std::find(m_lEvents.begin(), m_lEvents.end(), sEvent) == m_lEvents.end())
+ return;
} /* SAFE */
@@ -252,32 +249,33 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
catch( const css::uno::Exception& )
{}
- /* SAFE */ {
- osl::MutexGuard g(rBHelper.rMutex);
-
- // Special feature: If the events "OnNew" or "OnLoad" occurs - we generate our own event "onDocumentOpened".
- if (
- (aEvent.EventName == "OnNew") ||
- (aEvent.EventName == "OnLoad")
- )
+ /* SAFE */
{
- if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end())
- JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_OPENED, lJobs);
- }
+ std::unique_lock g(m_aMutex);
- // Special feature: If the events "OnCreate" or "OnLoadFinished" occurs - we generate our own event "onDocumentAdded".
- if (
- (aEvent.EventName == "OnCreate") ||
- (aEvent.EventName == "OnLoadFinished")
- )
- {
- if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end())
- JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_ADDED, lJobs);
- }
+ // Special feature: If the events "OnNew" or "OnLoad" occurs - we generate our own event "onDocumentOpened".
+ if (
+ (aEvent.EventName == "OnNew") ||
+ (aEvent.EventName == "OnLoad")
+ )
+ {
+ if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end())
+ JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_OPENED, lJobs);
+ }
+
+ // Special feature: If the events "OnCreate" or "OnLoadFinished" occurs - we generate our own event "onDocumentAdded".
+ if (
+ (aEvent.EventName == "OnCreate") ||
+ (aEvent.EventName == "OnLoadFinished")
+ )
+ {
+ if (std::find(m_lEvents.begin(), m_lEvents.end(), EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end())
+ JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_ADDED, lJobs);
+ }
- // Add all jobs for "real" notified event too .-)
- if (std::find(m_lEvents.begin(), m_lEvents.end(), aEvent.EventName) != m_lEvents.end())
- JobData::appendEnabledJobsForEvent(m_xContext, aEvent.EventName, lJobs);
+ // Add all jobs for "real" notified event too .-)
+ if (std::find(m_lEvents.begin(), m_lEvents.end(), aEvent.EventName) != m_lEvents.end())
+ JobData::appendEnabledJobsForEvent(m_xContext, aEvent.EventName, lJobs);
} /* SAFE */
// step over all enabled jobs and execute it
@@ -359,7 +357,7 @@ void SAL_CALL JobExecutor::elementReplaced( const css::container::ContainerEvent
void SAL_CALL JobExecutor::disposing( const css::lang::EventObject& aEvent )
{
/* SAFE { */
- osl::MutexGuard g(rBHelper.rMutex);
+ std::unique_lock g(m_aMutex);
css::uno::Reference< css::uno::XInterface > xCFG(m_aConfig.cfg(), css::uno::UNO_QUERY);
if (
(xCFG == aEvent.Source ) &&