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::mutex tasks_mutex_;
72 };
73 } // namespace GpgFrontend::Thread
74 
75 #endif // GPGFRONTEND_TASKRUNNER_H
GpgFrontend::Thread::TaskRunner
Definition: TaskRunner.h:39
GpgFrontend::Thread::TaskRunner::PostTask
void PostTask(Task *task)
Definition: TaskRunner.cpp:36
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:71
GpgFrontend::Thread::Task
Definition: Task.h:38
GpgFrontend::Thread::TaskRunner::~TaskRunner
virtual ~TaskRunner() override
Destroy the Task Runner object.