4 #include "lang/verify.h"
6 // if blocking, then addJob() blocks when queue is full
7 // otherwise, addJob() simply returns false when queue is full
8 ThrPool::ThrPool(int sz, bool blocking)
9 : nthreads_(sz),blockadd_(blocking),jobq_(100*sz)
11 for (int i=0; i<nthreads_; i++)
12 th_.emplace_back(&ThrPool::do_worker, this);
15 // IMPORTANT: this function can be called only when no external thread
16 // will ever use this thread pool again or is currently blocking on it
19 for (int i=0; i<nthreads_; i++)
22 for (int i=0; i<nthreads_; i++)
27 ThrPool::addJob(const job_t &j)
29 return jobq_.enq(j,blockadd_);