diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-01-01 11:49:05 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-01-01 11:49:05 +0200 |
commit | 9e8b86bb9ef84d6214a9ea2110cf6ed83f4ddcd3 (patch) | |
tree | 30a84942f54f2df95d8ae77f970f67681d34fa80 /build2/scheduler.hxx | |
parent | fbd86a218a4477fb505aff76713f3bd75d683a38 (diff) |
Fix race in scheduler progress setting logic
Diffstat (limited to 'build2/scheduler.hxx')
-rw-r--r-- | build2/scheduler.hxx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/build2/scheduler.hxx b/build2/scheduler.hxx index f79ca3e..20e5128 100644 --- a/build2/scheduler.hxx +++ b/build2/scheduler.hxx @@ -160,6 +160,7 @@ namespace build2 // If the maximum threads or task queue depth arguments are unspecified, // then appropriate defaults are used. // + explicit scheduler (size_t max_active, size_t init_active = 1, size_t max_threads = 0, @@ -197,7 +198,7 @@ namespace build2 void tune (size_t max_active); - // Return true if the scheduler is running serial. + // Return true if the scheduler is configured to run tasks serially. // // Note: can only be called from threads that have observed startup. // @@ -255,6 +256,7 @@ namespace build2 { if (s_ != nullptr) { + s_->wait_idle (); // See monitor() for details. s_->monitor_count_ = nullptr; s_->monitor_func_ = nullptr; } @@ -298,6 +300,12 @@ namespace build2 task_queue_ = nullptr; } + // Assuming all the task have been executed, busy-wait for all the threads + // to become idle. Normally you don't need to call this function directly. + // + void + wait_idle (); + // Return the number of hardware threads or 0 if unable to determine. // static size_t |