neic-glass3  1.4.6
threadpool.h
Go to the documentation of this file.
1 /*****************************************
2  * This file is documented for Doxygen.
3  * If you modify this file please update
4  * the comments so that Doxygen will still
5  * be able to work.
6  ****************************************/
7 #ifndef THREADPOOL_H
8 #define THREADPOOL_H
9 
10 #include <baseclass.h>
11 #include <threadbaseclass.h>
12 #include <threadstate.h>
13 #include <thread>
14 #include <mutex>
15 #include <queue>
16 #include <ctime>
17 #include <string>
18 
19 namespace glass3 {
20 namespace util {
32  public:
39  ThreadPool();
40 
57  explicit ThreadPool(std::string poolName, int numThreads = 5,
58  int sleepTime = 100, int checkInterval = 300);
59 
65  ~ThreadPool();
66 
77  void addJob(std::function<void()> newJob);
78 
87  int getJobQueueSize();
88 
99  glass3::util::WorkState work() override;
100 
101  private:
106  std::queue<std::function<void()>> m_JobQueue;
107 
112  std::mutex & getMutex();
113 
117  std::mutex m_Mutex;
118 };
119 } // namespace util
120 } // namespace glass3
121 #endif // THREADPOOL_H
ThreadPool()
ThreadPool constructor.
Definition: threadpool.cpp:9
glass3::util::ThreadPool class
Definition: threadpool.h:31
threadstatus.h
int getJobQueueSize()
Retrieve the current number of jobs in the queue.
Definition: threadpool.cpp:80
The neic-glass3 project namespace containing all the classes and functions that make up neic-glass3...
WorkState
glass3::util::WorkState enumeration
Definition: workstate.h:25
void addJob(std::function< void()> newJob)
add a new job for for the thread pool to process
Definition: threadpool.cpp:25
glass3::util::WorkState work() override
ThreadBaseClass work function.
Definition: threadpool.cpp:36
~ThreadPool()
ThreadPool destructor.
Definition: threadpool.cpp:21
glass3::util::ThreadBaseClass class
Definition: threadbaseclass.h:34