X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/5fd8cc8409d0efadc07dfe8d6774ad9ff477663d..e478ac59e66e89cbc174e781ac715c8644539947:/rpc/thr_pool.cc diff --git a/rpc/thr_pool.cc b/rpc/thr_pool.cc index f9f32fa..64b3263 100644 --- a/rpc/thr_pool.cc +++ b/rpc/thr_pool.cc @@ -1,69 +1,33 @@ -#include "slock.h" #include "thr_pool.h" -#include -#include -#include "lang/verify.h" -static void * -do_worker(void *arg) -{ - ThrPool *tp = (ThrPool *)arg; - while (1) { - ThrPool::job_t j; - if (!tp->takeJob(&j)) - break; //die - - (void)(j.f)(j.a); - } - pthread_exit(NULL); +// if blocking, then addJob() blocks when queue is full +// otherwise, addJob() simply returns false when queue is full +ThrPool::ThrPool(size_t sz, bool blocking) +: nthreads_(sz),blockadd_(blocking),jobq_(100*sz) { + for (size_t i=0; if!=NULL); -} -