From a9e3e3f08717dde1d10ff3f8192019596462261f Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Thu, 18 Aug 2016 20:16:05 +0300 Subject: [PATCH] Possible one more performance increasing Lets try to use own QueuedConnection type instead of default AutoConnection. To implement it we need to disconnect all default slots and reconnect them with specified connection type --- .../plugin/awdataengineaggregator.cpp | 34 +++++++++++++++++++ .../plugin/awdataengineaggregator.h | 1 + 2 files changed, 35 insertions(+) diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.cpp b/sources/awesome-widget/plugin/awdataengineaggregator.cpp index 9148b73..71c2c73 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataengineaggregator.cpp @@ -17,6 +17,8 @@ #include "awdataengineaggregator.h" +#include + #include "awdebug.h" #include "awkeys.h" @@ -25,6 +27,9 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *parent) : QObject(parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + // required to define Qt::QueuedConnection for signal-slot connection + qRegisterMetaType("Plasma::DataEngine::Data"); } @@ -98,4 +103,33 @@ void AWDataEngineAggregator::reconnectSources(const int interval) m_dataEngines[QString("extsysmon")]->connectAllSources(parent(), interval); m_dataEngines[QString("time")]->connectSource(QString("Local"), parent(), 1000); + +#ifdef BUILD_FUTURE + createQueuedConnection(); +#endif /* BUILD_FUTURE */ +} + + +void AWDataEngineAggregator::createQueuedConnection() +{ + // HACK additional method which forces QueuedConnection instead of Auto one + // for more details refer to plasma-framework source code + for (auto dataEngine : m_dataEngines.keys()) { + // different source set for different engines + QStringList sources; + if (dataEngine == QString("time")) + sources.append(QString("Local")); + else + sources = m_dataEngines[dataEngine]->sources(); + // reconnect sources + for (auto source : sources) { + Plasma::DataContainer *container =m_dataEngines[dataEngine]->containerForSource(source); + // disconnect old connections first + disconnect(container, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), + parent(), SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); + // and now reconnect with Qt::QueuedConnection type + connect(container, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), + parent(), SLOT(dataUpdated(QString,Plasma::DataEngine::Data)), Qt::QueuedConnection); + } + } } diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.h b/sources/awesome-widget/plugin/awdataengineaggregator.h index 11afab3..fb4bfe8 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.h +++ b/sources/awesome-widget/plugin/awdataengineaggregator.h @@ -44,6 +44,7 @@ public slots: void reconnectSources(const int interval); private: + void createQueuedConnection(); Plasma::DataEngineConsumer *m_consumer = nullptr; QHash m_dataEngines; };