diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-01-26 16:01:58 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-13 12:42:33 +0200 |
commit | 93dbdacafb07b674467aa30c4aefd38bb3871601 (patch) | |
tree | 6675150a587b560193ef21ae1d334300655e9d8e /build2/scheduler.cxx | |
parent | 88f0780e34116c0441a8d8c58b8a8fd9fde4b1f5 (diff) |
Add scheduling calls to operation's match()
Diffstat (limited to 'build2/scheduler.cxx')
-rw-r--r-- | build2/scheduler.cxx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/build2/scheduler.cxx b/build2/scheduler.cxx index be50b28..9abafbb 100644 --- a/build2/scheduler.cxx +++ b/build2/scheduler.cxx @@ -146,7 +146,7 @@ namespace build2 max_active <= max_threads); active_ = init_active_ = init_active; - max_active_ = max_active; + max_active_ = orig_max_active_ = max_active; max_threads_ = max_threads; // This value should be proportional to the amount of hardware concurrency @@ -212,12 +212,32 @@ namespace build2 wait_queue_[i].shutdown = false; } + void scheduler:: + tune (size_t max_active) + { + lock l (mutex_); + + if (max_active) + max_active = orig_max_active_; + + assert (max_active >= init_active_ && + max_active <= orig_max_active_); + + // The schduler must not be active. + // + assert (active_ == init_active_); + assert (waiting_ == 0); + assert (ready_ == 0); + + max_active_ = max_active; + } + auto scheduler:: shutdown () -> stat { // Our overall approach to shutdown is not to try and stop everything as // quickly as possible but rather to avoid performing any tasks. This - // avoids having code littered with if(shutdown) on every second line. + // avoids having code littered with if(shutdown) on every other line. stat r; lock l (mutex_); @@ -274,7 +294,7 @@ namespace build2 wait_queue_.reset (); task_queues_.clear (); - r.thread_max_active = max_active_; + r.thread_max_active = orig_max_active_; r.thread_max_total = max_threads_; r.thread_max_waiting = stat_max_waiters_; |