X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/5fd8cc8409d0efadc07dfe8d6774ad9ff477663d..f0dcb6b97d6d40f67698d1f71ac26970f1776f82:/rpc/thr_pool.cc diff --git a/rpc/thr_pool.cc b/rpc/thr_pool.cc index f9f32fa..fc7be3d 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 +thread_pool::thread_pool(size_t sz, bool blocking) +: nthreads_(sz),blockadd_(blocking),jobq_(100*sz) { + for (size_t i=0; if!=NULL); -} -