GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
TaskRunner.h
1 
27 #ifndef GPGFRONTEND_TASKRUNNER_H
28 #define GPGFRONTEND_TASKRUNNER_H
29 
30 #include <cstddef>
31 #include <mutex>
32 #include <queue>
33 
34 #include "core/GpgFrontendCore.h"
35 
36 namespace GpgFrontend::Thread {
37 
38 class Task;
39 
40 class GPGFRONTEND_CORE_EXPORT TaskRunner : public QThread {
41  Q_OBJECT
42  public:
48 
53  virtual ~TaskRunner() override;
54 
59  [[noreturn]] void run() override;
60 
61  public slots:
62 
68  void PostTask(Task* task);
69 
76  void PostScheduleTask(Task* task, size_t seconds);
77 
78  private:
79  std::queue<Task*> tasks;
80  std::map<std::string, Task*> pending_tasks_;
81  std::mutex tasks_mutex_;
82 };
83 } // namespace GpgFrontend::Thread
84 
85 #endif // GPGFRONTEND_TASKRUNNER_H
Definition: TaskRunner.h:40
std::mutex tasks_mutex_
The task queue mutex.
Definition: TaskRunner.h:81
std::map< std::string, Task * > pending_tasks_
The pending tasks.
Definition: TaskRunner.h:80
std::queue< Task * > tasks
The task queue.
Definition: TaskRunner.h:79
virtual ~TaskRunner() override
Destroy the Task Runner object.
TaskRunner()
Construct a new Task Runner object.
Definition: Task.h:45
Definition: CtxCheckTask.h:33