diff options
author | saturneric <[email protected]> | 2023-10-18 12:54:02 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2023-10-18 12:54:02 +0000 |
commit | 76fda183d4c1067ab1735965e9bde3c7b29d1345 (patch) | |
tree | 54723eb8698dfe6f7e5dbc4c16b9da16e192d44b /src/core/thread/TaskRunner.h | |
parent | fix: improve thread and module relation (diff) | |
download | GpgFrontend-76fda183d4c1067ab1735965e9bde3c7b29d1345.tar.gz GpgFrontend-76fda183d4c1067ab1735965e9bde3c7b29d1345.zip |
feat: simplify the thread system and improve its stability
Diffstat (limited to 'src/core/thread/TaskRunner.h')
-rw-r--r-- | src/core/thread/TaskRunner.h | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/core/thread/TaskRunner.h b/src/core/thread/TaskRunner.h index f388a4f6..25187178 100644 --- a/src/core/thread/TaskRunner.h +++ b/src/core/thread/TaskRunner.h @@ -29,17 +29,13 @@ #ifndef GPGFRONTEND_TASKRUNNER_H #define GPGFRONTEND_TASKRUNNER_H -#include <cstddef> -#include <mutex> -#include <queue> - #include "core/GpgFrontendCore.h" namespace GpgFrontend::Thread { class Task; -class GPGFRONTEND_CORE_EXPORT TaskRunner : public QThread { +class GPGFRONTEND_CORE_EXPORT TaskRunner : public QObject { Q_OBJECT public: /** @@ -54,11 +50,11 @@ class GPGFRONTEND_CORE_EXPORT TaskRunner : public QThread { */ virtual ~TaskRunner() override; - /** - * @brief - * - */ - [[noreturn]] void run() override; + void Start(); + + QThread* GetThread(); + + bool IsRunning(); public slots: @@ -78,16 +74,8 @@ class GPGFRONTEND_CORE_EXPORT TaskRunner : public QThread { void PostScheduleTask(Task* task, size_t seconds); private: - std::queue<Task*> tasks; ///< The task queue - std::map<std::string, Task*> pending_tasks_; ///< The pending tasks - std::mutex tasks_mutex_; ///< The task queue mutex - QThreadPool thread_pool_{this}; ///< run non-sequency task - - /** - * @brief - * - */ - void unregister_finished_task(std::string); + class Impl; + std::unique_ptr<Impl> p_; }; } // namespace GpgFrontend::Thread |