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 <mutex>
31 #include <queue>
32 
33 #include "core/GpgFrontendCore.h"
34 
35 namespace GpgFrontend::Thread {
36 
37 class Task;
38 
39 class GPGFRONTEND_CORE_EXPORT TaskRunner : public QThread {
40  Q_OBJECT
41  public:
46  TaskRunner();
47 
52  virtual ~TaskRunner() override;
53 
58  void run() override;
59 
60  public slots:
61 
67  void PostTask(Task* task);
68 
69  private:
70  std::queue<Task*> tasks;
71  std::map<std::string, Task*> pending_tasks_;
72  std::mutex tasks_mutex_;
73 };
74 } // namespace GpgFrontend::Thread
75 
76 #endif // GPGFRONTEND_TASKRUNNER_H
GpgFrontend::Thread::TaskRunner
Definition: TaskRunner.h:39
GpgFrontend::Thread::TaskRunner::PostTask
void PostTask(Task *task)
Definition: TaskRunner.cpp:38
GpgFrontend::Thread
Definition: CtxCheckTask.h:33
GpgFrontend::Thread::TaskRunner::TaskRunner
TaskRunner()
Construct a new Task Runner object.
GpgFrontend::Thread::TaskRunner::tasks
std::queue< Task * > tasks
The task queue.
Definition: TaskRunner.h:70
GpgFrontend::Thread::TaskRunner::tasks_mutex_
std::mutex tasks_mutex_
The task queue mutex.
Definition: TaskRunner.h:72
GpgFrontend::Thread::TaskRunner::pending_tasks_
std::map< std::string, Task * > pending_tasks_
The pending tasks.
Definition: TaskRunner.h:71
GpgFrontend::Thread::Task
Definition: Task.h:45
GpgFrontend::Thread::Task::GetUUID
std::string GetUUID() const
Definition: Task.cpp:71
GpgFrontend::Thread::TaskRunner::~TaskRunner
virtual ~TaskRunner() override
Destroy the Task Runner object.