Added id to InsightWorker objects
This commit is contained in:
@@ -181,7 +181,7 @@ namespace Bloom
|
||||
|
||||
// Prepare worker thread
|
||||
this->workerThread = new QThread();
|
||||
this->workerThread->setObjectName("IW");
|
||||
this->workerThread->setObjectName("IW" + QString::number(this->insightWorker->id));
|
||||
this->insightWorker->moveToThread(this->workerThread);
|
||||
QObject::connect(this->workerThread, &QThread::started, this->insightWorker, &InsightWorker::startup);
|
||||
QObject::connect(this->workerThread, &QThread::finished, this->insightWorker, &QObject::deleteLater);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Bloom
|
||||
using Bloom::Targets::TargetState;
|
||||
|
||||
void InsightWorker::startup() {
|
||||
Logger::debug("Starting InsightWorker thread");
|
||||
Logger::debug("Starting InsightWorker" + std::to_string(this->id) + " thread");
|
||||
|
||||
QObject::connect(
|
||||
InsightSignals::instance(),
|
||||
@@ -21,6 +21,7 @@ namespace Bloom
|
||||
&InsightWorker::executeTasks
|
||||
);
|
||||
|
||||
Logger::debug("InsightWorker" + std::to_string(this->id) + " thread ready");
|
||||
emit this->ready();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <atomic>
|
||||
#include <QtCore>
|
||||
#include <queue>
|
||||
|
||||
@@ -10,6 +12,8 @@
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
static_assert(std::atomic<std::uint8_t>::is_always_lock_free);
|
||||
|
||||
/**
|
||||
* The InsightWorker runs on a separate thread to the main GUI thread. Its purpose is to handle any
|
||||
* blocking/time-expensive operations.
|
||||
@@ -19,8 +23,9 @@ namespace Bloom
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InsightWorker() = default;
|
||||
const std::uint8_t id = ++(InsightWorker::lastWorkerId);
|
||||
|
||||
InsightWorker() = default;
|
||||
void startup();
|
||||
static void queueTask(InsightWorkerTask* task);
|
||||
|
||||
@@ -28,10 +33,11 @@ namespace Bloom
|
||||
void ready();
|
||||
|
||||
private:
|
||||
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole();
|
||||
|
||||
static inline std::atomic<std::uint8_t> lastWorkerId = 0;
|
||||
static inline SyncSafe<std::queue<InsightWorkerTask*>> queuedTasks = {};
|
||||
|
||||
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole();
|
||||
|
||||
static std::optional<InsightWorkerTask*> getQueuedTask();
|
||||
void executeTasks();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user