Commit b2f51097 authored by Karel Slaný's avatar Karel Slaný

Moved worker pool into shared folder.

parent 69abba19
......@@ -94,6 +94,7 @@ SOURCES += \
src/datovka_shared/io/sqlite/db.cpp \
src/datovka_shared/io/sqlite/db_single.cpp \
src/datovka_shared/io/sqlite/table.cpp \
src/datovka_shared/worker/pool.cpp \
src/dialogues/dialogues.cpp \
src/dialogues/qml_dialogue_helper.cpp \
src/dialogues/qml_input_dialogue.cpp \
......@@ -134,7 +135,6 @@ SOURCES += \
src/sqlite/zfo_db.cpp \
src/utility/rand_string.cpp \
src/worker/emitter.cpp \
src/worker/pool.cpp \
src/worker/task.cpp \
src/worker/task_change_password.cpp \
src/worker/task_download_account_info.cpp \
......@@ -156,6 +156,7 @@ HEADERS += \
src/datovka_shared/io/sqlite/db.h \
src/datovka_shared/io/sqlite/db_single.h \
src/datovka_shared/io/sqlite/table.h \
src/datovka_shared/worker/pool.h \
src/dialogues/dialogues.h \
src/dialogues/qml_dialogue_helper.h \
src/dialogues/qml_input_dialogue.h \
......@@ -196,7 +197,6 @@ HEADERS += \
src/sqlite/zfo_db.h \
src/utility/rand_string.h \
src/worker/emitter.h \
src/worker/pool.h \
src/worker/task.h \
src/worker/task_change_password.h \
src/worker/task_download_account_info.h \
......
......@@ -21,7 +21,7 @@
* the two.
*/
#include "src/worker/pool.h"
#include "src/datovka_shared/worker/pool.h"
WorkerThread::WorkerThread(WorkerPool *pool)
: m_pool(pool)
......@@ -145,7 +145,7 @@ void WorkerPool::runSingle(QRunnable *task)
}
m_lock.lock();
while (0 != m_singleTask) {
while (Q_NULLPTR != m_singleTask) {
m_wake.wait(&m_lock);
}
m_singleTask = task;
......@@ -157,7 +157,7 @@ void WorkerPool::runSingle(QRunnable *task)
while (FINISHED != m_singleState) {
m_wake.wait(&m_lock);
}
m_singleTask = 0; /* Leave in FINISHED. */
m_singleTask = Q_NULLPTR; /* Leave in FINISHED. */
m_wake.wakeAll();
m_lock.unlock();
}
......@@ -191,7 +191,7 @@ bool WorkerPool::working(void)
bool isWorking = false;
m_lock.lock();
isWorking = !((0 == m_running) && (0 == m_singleTask) &&
isWorking = !((0 == m_running) && (Q_NULLPTR == m_singleTask) &&
m_tasksHi.isEmpty() && m_tasksLo.isEmpty());
m_lock.unlock();
......@@ -211,7 +211,7 @@ void WorkerPool::run(WorkerPool *pool)
QRunnable *task = Q_NULLPTR;
if (!pool->m_suspended) {
if ((0 != pool->m_singleTask) && (PENDING == pool->m_singleState)) {
if ((Q_NULLPTR != pool->m_singleTask) && (PENDING == pool->m_singleState)) {
task = pool->m_singleTask;
pool->m_singleState = EXECUTING;
} else if (!pool->m_tasksHi.isEmpty()) {
......@@ -223,7 +223,7 @@ void WorkerPool::run(WorkerPool *pool)
}
}
if (0 == task) {
if (Q_NULLPTR == task) {
pool->m_wake.wait(&pool->m_lock);
continue;
}
......
......@@ -21,8 +21,7 @@
* the two.
*/
#ifndef _POOL_H_
#define _POOL_H_
#pragma once
#include <QMutex>
#include <QQueue>
......@@ -38,8 +37,6 @@
* Worker objects are unnecessary.
*/
class WorkerPool;
/*!
* @brief Worker.
*/
......@@ -52,7 +49,7 @@ public:
*
* @param[in] pool Pointer to be stored.
*/
WorkerThread(WorkerPool *pool);
explicit WorkerThread(class WorkerPool *pool);
protected:
/*!
......@@ -64,7 +61,7 @@ protected:
friend class WorkerPool;
private:
WorkerPool *m_pool; /* Pointer to worker pool, must be non-null. */
class WorkerPool *m_pool; /* Pointer to worker pool, must be non-null. */
};
/*!
......@@ -88,7 +85,7 @@ public:
* @param[in] threads Number of threads to create.
* @param[in] parent Object parent.
*/
WorkerPool(unsigned threads, QObject *parent = 0);
explicit WorkerPool(unsigned threads, QObject *parent = Q_NULLPTR);
/*!
* @brief Destructor.
......@@ -227,5 +224,3 @@ private:
enum ExecutionState m_singleState; /*!< Single execution state. */
};
#endif /* _POOL_H_ */
......@@ -26,12 +26,12 @@
#include <QObject>
#include "src/datovka_shared/worker/pool.h"
#include "src/messages.h"
#include "src/net/db_wrapper.h"
#include "src/net/net_layer.h"
#include "src/net/isds_const.h"
#include "src/net/isds_session.h"
#include "src/worker/pool.h"
#include "src/worker/task_send_message.h"
class MessageListModel; /* Forward declaration. */
......
......@@ -21,10 +21,11 @@
* the two.
*/
#include <QThread>
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_change_password.h"
TaskChangePassword::TaskChangePassword(IsdsSession::IsdsContext &ctx,
......
......@@ -21,11 +21,12 @@
* the two.
*/
#include <QThread>
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/emitter.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_download_account_info.h"
TaskDownloadAccountInfo::TaskDownloadAccountInfo(IsdsSession::IsdsContext &ctx,
......
......@@ -21,11 +21,12 @@
* the two.
*/
#include <QThread>
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/emitter.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_download_delivery_info.h"
TaskDownloadDeliveryInfo::TaskDownloadDeliveryInfo(IsdsSession::IsdsContext &ctx,
......
......@@ -21,13 +21,14 @@
* the two.
*/
#include <QThread>
#include "src/log/log.h"
#include "src/io/filesystem.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/qml_interaction/message_envelope.h"
#include "src/worker/emitter.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_download_message.h"
#include "src/sqlite/message_db_container.h"
......
......@@ -21,12 +21,14 @@
* the two.
*/
#include <QThread>
#include "src/datovka_shared/worker/pool.h" /* List with whole messages. */
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/qml_interaction/message_envelope.h"
#include "src/worker/emitter.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_download_message.h"
#include "src/worker/task_download_message_list.h"
#include "src/sqlite/message_db_container.h"
......
......@@ -26,13 +26,13 @@
#include <QString>
#include "src/datovka_shared/worker/pool.h"
#include "src/messages.h"
#include "src/models/accountmodel.h"
#include "src/models/messagemodel.h"
#include "src/net/isds_session.h"
#include "src/net/db_wrapper.h"
#include "src/net/net_layer.h"
#include "src/worker/pool.h"
#include "src/worker/task.h"
......
......@@ -21,10 +21,11 @@
* the two.
*/
#include <QThread>
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/pool.h"
#include "src/worker/task_find_databox.h"
TaskFindDatabox::TaskFindDatabox(IsdsSession::IsdsContext &ctx,
......
......@@ -21,11 +21,12 @@
* the two.
*/
#include <QThread>
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/emitter.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_find_databox_fulltext.h"
TaskFindDataboxFulltext::TaskFindDataboxFulltext(IsdsSession::IsdsContext &ctx,
......
......@@ -21,12 +21,13 @@
* the two.
*/
#include <QThread>
#include "src/auxiliaries/attachment_helper.h"
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/emitter.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_send_message.h"
TaskSendMessage::ResultData::ResultData(void)
......
......@@ -21,10 +21,11 @@
* the two.
*/
#include <QThread>
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_send_sms.h"
TaskSendSMS::TaskSendSMS(IsdsSession::IsdsContext &ctx, NetLayer *netLayer)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment