summaryrefslogtreecommitdiff
path: root/src/buildtool/multithreading/task_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/multithreading/task_system.cpp')
-rw-r--r--src/buildtool/multithreading/task_system.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/buildtool/multithreading/task_system.cpp b/src/buildtool/multithreading/task_system.cpp
index 4af57d0d..ee5be910 100644
--- a/src/buildtool/multithreading/task_system.cpp
+++ b/src/buildtool/multithreading/task_system.cpp
@@ -17,12 +17,7 @@ TaskSystem::TaskSystem(std::size_t number_of_threads)
}
TaskSystem::~TaskSystem() {
- // When starting a new task system all spawned threads will immediately go
- // to sleep and wait for tasks. Even after adding some tasks, it can take a
- // while until the first thread wakes up. Therefore, we need to wait for the
- // total workload (number of active threads _and_ total number of queued
- // tasks) to become zero.
- total_workload_.WaitForZero();
+ Finish();
for (auto& q : queues_) {
q.done();
}
@@ -31,6 +26,15 @@ TaskSystem::~TaskSystem() {
}
}
+void TaskSystem::Finish() noexcept {
+ // When starting a new task system all spawned threads will immediately go
+ // to sleep and wait for tasks. Even after adding some tasks, it can take a
+ // while until the first thread wakes up. Therefore, we need to wait for the
+ // total workload (number of active threads _and_ total number of queued
+ // tasks) to become zero.
+ total_workload_.WaitForZero();
+}
+
void TaskSystem::Run(std::size_t idx) {
gsl_Expects(thread_count_ > 0);