MOAR TEMPLATE MAGIC
[invirt/third/libt4.git] / rpc / thr_pool.cc
index 146764f..8b9691b 100644 (file)
@@ -1,25 +1,22 @@
 #include "thr_pool.h"
-#include <stdlib.h>
-#include <errno.h>
-#include "lang/verify.h"
 
 // if blocking, then addJob() blocks when queue is full
 // otherwise, addJob() simply returns false when queue is full
-ThrPool::ThrPool(int sz, bool blocking)
+ThrPool::ThrPool(size_t sz, bool blocking)
 : nthreads_(sz),blockadd_(blocking),jobq_(100*sz) 
 {
-       for (int i=0; i<nthreads_; i++)
-        th_.push_back(std::thread(&ThrPool::do_worker, this));
+       for (size_t i=0; i<nthreads_; i++)
+        th_.emplace_back(&ThrPool::do_worker, this);
 }
 
 // IMPORTANT: this function can be called only when no external thread 
 // will ever use this thread pool again or is currently blocking on it
 ThrPool::~ThrPool()
 {
-       for (int i=0; i<nthreads_; i++)
+       for (size_t i=0; i<nthreads_; i++)
                jobq_.enq(job_t());
 
-       for (int i=0; i<nthreads_; i++)
+       for (size_t i=0; i<nthreads_; i++)
         th_[i].join();
 }