about summary refs log tree commit diff
path: root/src/libutil/util.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/util.hh
parent6a888ec29a6724f916f96508b3a94a86c643c18e (diff)
ThreadPool: On exception, interrupt the other worker threads
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r--src/libutil/util.hh5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 30e3c0df1c1a..6a66576e96ce 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -273,13 +273,16 @@ void closeOnExec(int fd);
 
 extern bool _isInterrupted;
 
+extern thread_local std::function<bool()> interruptCheck;
+
 void setInterruptThrown();
 
 void _interrupted();
 
 void inline checkInterrupt()
 {
-    if (_isInterrupted) _interrupted();
+    if (_isInterrupted || (interruptCheck && interruptCheck()))
+        _interrupted();
 }
 
 MakeError(Interrupted, BaseError)