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)
8 for (size_t i=0; i<nthreads_; i++)
9 th_.emplace_back(&ThrPool::do_worker, this);
12 // IMPORTANT: this function can be called only when no external thread
13 // will ever use this thread pool again or is currently blocking on it
16 for (size_t i=0; i<nthreads_; i++)
19 for (size_t i=0; i<nthreads_; i++)
24 ThrPool::addJob(const job_t &j)
26 return jobq_.enq(j,blockadd_);