about summary refs log tree commit diff
path: root/third_party/nix/src/libutil/thread-pool.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-18T01·34+0100
committerVincent Ambo <tazjin@google.com>2020-05-18T01·34+0100
commit6dc6c29fa4a4ddd3bb72f8415fac5936d719bd44 (patch)
tree560a8389d1682465599d94193053811acfd5de37 /third_party/nix/src/libutil/thread-pool.cc
parentc584480cd46fb49e690e931f326472e512a82878 (diff)
refactor(3p/nix/libutil): Replace internal logging library with glog r/754
Diffstat (limited to 'third_party/nix/src/libutil/thread-pool.cc')
-rw-r--r--third_party/nix/src/libutil/thread-pool.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/third_party/nix/src/libutil/thread-pool.cc b/third_party/nix/src/libutil/thread-pool.cc
index 5b5be926539d..3f50b6aaa2e6 100644
--- a/third_party/nix/src/libutil/thread-pool.cc
+++ b/third_party/nix/src/libutil/thread-pool.cc
@@ -1,5 +1,6 @@
 #include "thread-pool.hh"
 #include "affinity.hh"
+#include "glog/logging.h"
 
 namespace nix {
 
@@ -11,7 +12,7 @@ ThreadPool::ThreadPool(size_t _maxThreads) : maxThreads(_maxThreads) {
     if (!maxThreads) maxThreads = 1;
   }
 
-  debug("starting pool of %d threads", maxThreads - 1);
+  DLOG(INFO) << "starting pool of " << maxThreads - 1 << " threads";
 }
 
 ThreadPool::~ThreadPool() { shutdown(); }
@@ -26,18 +27,21 @@ void ThreadPool::shutdown() {
 
   if (workers.empty()) return;
 
-  debug("reaping %d worker threads", workers.size());
+  DLOG(INFO) << "reaping " << workers.size() << " worker threads";
 
   work.notify_all();
 
-  for (auto& thr : workers) thr.join();
+  for (auto& thr : workers) {
+    thr.join();
+  }
 }
 
 void ThreadPool::enqueue(const work_t& t) {
   auto state(state_.lock());
-  if (quit)
+  if (quit) {
     throw ThreadPoolShutDown(
         "cannot enqueue a work item while the thread pool is shutting down");
+  }
   state->pending.push(t);
   /* Note: process() also executes items, so count it as a worker. */
   if (state->pending.size() > state->workers.size() + 1 &&