Cosmetic improvements.
[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 function<void()> job_t;
8
9 class thread_pool {
10     public:
11         thread_pool(size_t sz, bool blocking=true);
12         ~thread_pool();
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         vector<thread> th_;
22
23         void do_worker();
24 };
25
26 #endif