about summary refs log tree commit diff
path: root/src/libutil/thread-pool.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-09-08T13·31+0200
committerEelco Dolstra <edolstra@gmail.com>2017-09-08T13·31+0200
commitb7376edf06e3836394503e16ec14af23c7615f22 (patch)
tree1ba2185c659f832628580e98073792e02c13be00 /src/libutil/thread-pool.hh
parent6a888ec29a6724f916f96508b3a94a86c643c18e (diff)
ThreadPool: On exception, interrupt the other worker threads
Diffstat (limited to 'src/libutil/thread-pool.hh')
-rw-r--r--src/libutil/thread-pool.hh4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libutil/thread-pool.hh b/src/libutil/thread-pool.hh
index 835dfb4b83..06a097ab5e 100644
--- a/src/libutil/thread-pool.hh
+++ b/src/libutil/thread-pool.hh
@@ -7,6 +7,7 @@
 #include <functional>
 #include <thread>
 #include <map>
+#include <atomic>
 
 namespace nix {
 
@@ -47,9 +48,10 @@ private:
         size_t active = 0;
         std::exception_ptr exception;
         std::vector<std::thread> workers;
-        bool quit = false;
     };
 
+    std::atomic_bool quit{false};
+
     Sync<State> state_;
 
     std::condition_variable work, done;