diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2021-10-22 15:50:47 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-07-06 18:49:49 +0200 |
commit | a71a4b5015327b15fb0bb4fea16c43f21ef0616c (patch) | |
tree | 10596e9c89659845c7cc6d3bf632a07fe407af86 /src/buildtool/multithreading/task_system.hpp | |
parent | dc1129c79931d4391c3bcf6b629758fab7038219 (diff) | |
download | justbuild-a71a4b5015327b15fb0bb4fea16c43f21ef0616c.tar.gz |
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.
Diffstat (limited to 'src/buildtool/multithreading/task_system.hpp')
-rw-r--r-- | src/buildtool/multithreading/task_system.hpp | 3 |
1 files changed, 1 insertions, 2 deletions
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<std::thread> threads_{}; std::vector<NotificationQueue> queues_{}; std::atomic<std::size_t> index_{0}; - WaitableOneWayFlag queues_read_{}; - WaitableZeroCounter num_threads_running_{}; + WaitableZeroCounter total_workload_{}; static constexpr std::size_t kNumberOfAttempts = 5; |