# GpgFrontend Project: src/core/thread/TaskRunner.h Source File

TaskRunner.h
#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 {
Q_OBJECT
public:
TaskRunner();
virtual ~TaskRunner() override;
[[noreturn]] void run() override;
public slots:
void PostTask(Task* task);
void PostScheduleTask(Task* task, size_t seconds);
private:
std::queue<Task*> tasks;
std::map<std::string, Task*> pending_tasks_;
std::mutex tasks_mutex_;
QThreadPool thread_pool_{this};
void unregister_finished_task(std::string);
};
} // namespace GpgFrontend::Thread
#endif // GPGFRONTEND_TASKRUNNER_H
GpgFrontend::Thread::TaskRunner
Definition: TaskRunner.h:40
GpgFrontend::Thread::TaskRunner::tasks_mutex_
std::mutex tasks_mutex_
The task queue mutex.
Definition: TaskRunner.h:81
GpgFrontend::Thread::TaskRunner::pending_tasks_
std::map< std::string, Task * > pending_tasks_
The pending tasks.
Definition: TaskRunner.h:80
GpgFrontend::Thread::TaskRunner::tasks
std::queue< Task * > tasks
The task queue.
Definition: TaskRunner.h:79
GpgFrontend::Thread::TaskRunner::~TaskRunner
virtual ~TaskRunner() override
Destroy the Task Runner object.
GpgFrontend::Thread::TaskRunner::TaskRunner
TaskRunner()
Construct a new Task Runner object.
GpgFrontend::Thread::Task
Definition: Task.h:45
GpgFrontend::Thread
Definition: CtxCheckTask.h:33