TouchCPLib  1.0.0
A touch-enabled GUI interface based on SDL and libTS. It provides a simple desktop-free UI for your embedded Raspberry projects.
WorkerThread.h
Go to the documentation of this file.
1 #pragma once
2 
13 #include <deque>
14 #include <mutex>
15 #include <condition_variable>
16 #include <thread>
17 
18 #include "Task.h"
19 
26 {
27 public:
28  WorkerThread();
29  ~WorkerThread();
34  void runOnWorker(Task *task);
35 
36 private:
37  void workerThreadRunner();
38 
39  std::thread workerThread;
40  std::mutex taskDequeMutex;
41  std::condition_variable cv;
42  std::deque<Task *> taskDeque;
43  bool isRunning = true;
44 };
~WorkerThread()
Definition: WorkerThread.cpp:8
WorkerThread()
Definition: WorkerThread.cpp:3
A class that spawns an Executor Thread (or worker thread). The thread is used for handling intensive ...
Definition: WorkerThread.h:25
A task is an object that wraps the code to run on an thread.
Definition: Task.h:18
void runOnWorker(Task *task)
Adds a new task to the queue. It will be deleted when done.
Definition: WorkerThread.cpp:43