Fixed two major bugs in paxos.cc.
[invirt/third/libt4.git] / rpc / thr_pool.cc
index 7d3cf7d..64b3263 100644 (file)
@@ -4,30 +4,30 @@
 // otherwise, addJob() simply returns false when queue is full
 ThrPool::ThrPool(size_t sz, bool blocking)
 : nthreads_(sz),blockadd_(blocking),jobq_(100*sz) {
 // 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; i<nthreads_; i++)
+    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() {
         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 (size_t i=0; i<nthreads_; i++)
-               jobq_.enq(job_t());
+    for (size_t i=0; i<nthreads_; i++)
+        jobq_.enq(job_t());
 
 
-       for (size_t i=0; i<nthreads_; i++)
+    for (size_t i=0; i<nthreads_; i++)
         th_[i].join();
 }
 
 bool ThrPool::addJob(const job_t &j) {
         th_[i].join();
 }
 
 bool ThrPool::addJob(const job_t &j) {
-       return jobq_.enq(j,blockadd_);
+    return jobq_.enq(j,blockadd_);
 }
 
 void ThrPool::do_worker() {
     job_t j;
 }
 
 void ThrPool::do_worker() {
     job_t j;
-       while (1) {
+    while (1) {
         jobq_.deq(&j);
         jobq_.deq(&j);
-               if (!j)
-                       break;
-               j();
-       }
+        if (!j)
+            break;
+        j();
+    }
 }
 }