3 // if blocking, then addJob() blocks when queue is full
4 // otherwise, addJob() simply returns false when queue is full
5 ThrPool::ThrPool(size_t sz, bool blocking)
6 : nthreads_(sz),blockadd_(blocking),jobq_(100*sz) {
7 for (size_t i=0; i<nthreads_; i++)
8 th_.emplace_back(&ThrPool::do_worker, this);
11 // IMPORTANT: this function can be called only when no external thread
12 // will ever use this thread pool again or is currently blocking on it
14 for (size_t i=0; i<nthreads_; i++)
17 for (size_t i=0; i<nthreads_; i++)
21 bool ThrPool::addJob(const job_t &j) {
22 return jobq_.enq(j,blockadd_);
25 void ThrPool::do_worker() {