mirror of
				https://github.com/arcan1s/awesome-widgets.git
				synced 2025-10-31 05:13:40 +00:00 
			
		
		
		
	* add Optimization build type which uses -O3
* create QTimer object in AWDataEngineAggregator class, emit signal to this timer because timers could not be started in the separate thread * increase limit x2 with leaving the thread pool size as was
This commit is contained in:
		| @ -41,12 +41,14 @@ if(CMAKE_COMPILER_IS_GNUCXX) | ||||
|     set(CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++11") | ||||
|     set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") | ||||
|     set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") | ||||
|     set(CMAKE_CXX_FLAGS_OPTIMIZATION "-O3 -DNDEBUG") | ||||
|     # avoid newer gcc warnings | ||||
|     add_definitions(-D_DEFAULT_SOURCE) | ||||
| elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||||
|     set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -stdlib=libc++") | ||||
|     set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") | ||||
|     set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") | ||||
|     set(CMAKE_CXX_FLAGS_OPTIMIZATION "-O3 -DNDEBUG") | ||||
|     # linker flags | ||||
|     set(CMAKE_EXE_LINKER_FLAGS "-lc++abi") | ||||
|     set(CMAKE_MODULE_LINKER_FLAGS "-lc++abi") | ||||
|  | ||||
| @ -30,9 +30,16 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *parent, const int interv | ||||
| { | ||||
|     qCDebug(LOG_AW); | ||||
|  | ||||
|     // timer events | ||||
|     m_timer = new QTimer(this); | ||||
|     m_timer->setSingleShot(true); | ||||
|  | ||||
|     setInterval(interval); | ||||
|     initDataEngines(); | ||||
|     connectVisualization(); | ||||
|  | ||||
|     connect(this, SIGNAL(startTimer()), m_timer, SLOT(start())); | ||||
|     connect(m_timer, SIGNAL(timeout()), this, SLOT(connectVisualization())); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -41,6 +48,7 @@ AWDataEngineAggregator::~AWDataEngineAggregator() | ||||
|     qCDebug(LOG_AW); | ||||
|  | ||||
|     m_dataEngines.clear(); | ||||
|     if (m_timer != nullptr) delete m_timer; | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -50,6 +58,7 @@ void AWDataEngineAggregator::setInterval(const int _interval) | ||||
|     qCDebug(LOG_AW) << "Interval" << _interval; | ||||
|  | ||||
|     m_interval = _interval; | ||||
|     m_timer->setInterval(5 * _interval); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -57,6 +66,7 @@ void AWDataEngineAggregator::connectVisualization() | ||||
| { | ||||
|     qCDebug(LOG_AW); | ||||
|  | ||||
| //     reconnectSources(); | ||||
|     connect(this, SIGNAL(updateData(QString, QVariantMap)), | ||||
|             parent(), SLOT(dataUpdated(QString, QVariantMap))); | ||||
|  | ||||
| @ -70,8 +80,11 @@ void AWDataEngineAggregator::disconnectVisualization() | ||||
|  | ||||
|     disconnect(this, SIGNAL(updateData(QString, QVariantMap)), | ||||
|                parent(), SLOT(dataUpdated(QString, QVariantMap))); | ||||
| //     m_dataEngines.clear(); | ||||
|  | ||||
|     return QTimer::singleShot(5 * m_interval, this, SLOT(connectVisualization())); | ||||
|     // HACK run timer in the main thread since a timer could not be started from | ||||
|     // the different thread | ||||
|     return emit(startTimer()); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -23,6 +23,8 @@ | ||||
| #include <QObject> | ||||
|  | ||||
|  | ||||
| class QTimer; | ||||
|  | ||||
| class AWDataEngineAggregator : public QObject | ||||
| { | ||||
|     Q_OBJECT | ||||
| @ -35,6 +37,7 @@ public: | ||||
|     void setInterval(const int _interval); | ||||
|  | ||||
| signals: | ||||
|     void startTimer(); | ||||
|     void updateData(const QString sourceName, const QVariantMap sdata); | ||||
|  | ||||
| public slots: | ||||
| @ -52,6 +55,7 @@ private: | ||||
|     void initDataEngines(); | ||||
|     QHash<QString, Plasma::DataEngine *> m_dataEngines; | ||||
|     int m_interval; | ||||
|     QTimer *m_timer = nullptr; | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -49,7 +49,7 @@ AWKeys::AWKeys(QObject *parent) | ||||
|  | ||||
| #ifdef BUILD_FUTURE | ||||
|     // thread pool | ||||
|     queueLimit = QThread::idealThreadCount(); | ||||
|     queueLimit = 2 * QThread::idealThreadCount(); | ||||
|     threadPool = new QThreadPool(this); | ||||
| #endif /* BUILD_FUTURE */ | ||||
|  | ||||
| @ -115,11 +115,9 @@ void AWKeys::initKeys(const QString currentPattern, const int interval, const in | ||||
|     } else | ||||
|         dataEngineAggregator->setInterval(interval); | ||||
| #ifdef BUILD_FUTURE | ||||
|     // queue limit. It may be configured by using QUEUE_LIMIT cmake limit flag. | ||||
|     // In other hand since I'm using global thread pool, it makes sense to limit | ||||
|     // queue by QThread::idealThreadCount() value | ||||
|     queueLimit = limit == 0 ? QThread::idealThreadCount() : limit; | ||||
|     threadPool->setMaxThreadCount(queueLimit); | ||||
|     int rawLimit = (limit == 0 ? QThread::idealThreadCount() : limit); | ||||
|     queueLimit = 2 * rawLimit; | ||||
|     threadPool->setMaxThreadCount(rawLimit); | ||||
| #endif /* BUILD_FUTURE */ | ||||
|     updateCache(); | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user