More cleaning
[invirt/third/libt4.git] / rpc / thr_pool.h
1 #ifndef thr_pool_h
2 #define thr_pool_h
3
4 #include "types.h"
5 #include "fifo.h"
6
7 typedef std::function<void()> job_t;
8
9 class ThrPool {
10         public:
11                 ThrPool(size_t sz, bool blocking=true);
12                 ~ThrPool();
13
14                 bool addJob(const job_t &j);
15
16         private:
17         size_t nthreads_;
18                 bool blockadd_;
19
20                 fifo<job_t> jobq_;
21                 std::vector<std::thread> th_;
22
23         void do_worker();
24 };
25
26 #endif