From a71a4b5015327b15fb0bb4fea16c43f21ef0616c Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 22 Oct 2021 15:50:47 +0200 Subject: TaskSystem: Fix early shutdown ... conceptually, it was possible that a previous task decrements the `num_threads_running_` counter before it is incremented by the next task. Therefore, we have to unify the queue and thread status in a single counter (`total_workload_`) and ensure that woken threads increment it before decrementing it for popping a queue. --- src/buildtool/multithreading/task_system.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/buildtool/multithreading/task_system.hpp') diff --git a/src/buildtool/multithreading/task_system.hpp b/src/buildtool/multithreading/task_system.hpp index 20950142..6387988a 100644 --- a/src/buildtool/multithreading/task_system.hpp +++ b/src/buildtool/multithreading/task_system.hpp @@ -54,8 +54,7 @@ class TaskSystem { std::vector threads_{}; std::vector queues_{}; std::atomic index_{0}; - WaitableOneWayFlag queues_read_{}; - WaitableZeroCounter num_threads_running_{}; + WaitableZeroCounter total_workload_{}; static constexpr std::size_t kNumberOfAttempts = 5; -- cgit v1.2.3