diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-08-23 14:54:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-08-23 14:54:53 +0200 |
commit | 92dd62e0e565f177ab5861a9511bc0e303f61a79 (patch) | |
tree | 6ce394a50f60fa148336dfac5fb1bda46bd79e85 /libbuild2/context.cxx | |
parent | 542ad9696f50e33fa20e735c14c052720c55bc3a (diff) |
scheduler
Diffstat (limited to 'libbuild2/context.cxx')
-rw-r--r-- | libbuild2/context.cxx | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx index c454123..f4d8a39 100644 --- a/libbuild2/context.cxx +++ b/libbuild2/context.cxx @@ -55,7 +55,7 @@ namespace build2 sched (s), dry_run_option (dr), keep_going (kg), - phase_mutex (phase), + phase_mutex (*this), scopes (data_->scopes), global_scope (create_global_scope (data_->scopes)), targets (data_->targets), @@ -546,8 +546,6 @@ namespace build2 skip_count.store (0, memory_order_relaxed); } - scheduler sched; - bool run_phase_mutex:: lock (run_phase p) { @@ -573,16 +571,16 @@ namespace build2 // if (u) { - phase_ = p; + ctx_.phase = p; r = !fail_; } - else if (phase_ != p) + else if (ctx_.phase != p) { - sched.deactivate (false /* external */); - for (; phase_ != p; v->wait (l)) ; + ctx_.sched.deactivate (false /* external */); + for (; ctx_.phase != p; v->wait (l)) ; r = !fail_; l.unlock (); // Important: activate() can block. - sched.activate (false /* external */); + ctx_.sched.activate (false /* external */); } else r = !fail_; @@ -628,10 +626,10 @@ namespace build2 { condition_variable* v; - if (lc_ != 0) {phase_ = run_phase::load; v = &lv_;} - else if (mc_ != 0) {phase_ = run_phase::match; v = &mv_;} - else if (ec_ != 0) {phase_ = run_phase::execute; v = &ev_;} - else {phase_ = run_phase::load; v = nullptr;} + if (lc_ != 0) {ctx_.phase = run_phase::load; v = &lv_;} + else if (mc_ != 0) {ctx_.phase = run_phase::match; v = &mv_;} + else if (ec_ != 0) {ctx_.phase = run_phase::execute; v = &ev_;} + else {ctx_.phase = run_phase::load; v = nullptr;} if (v != nullptr) { @@ -678,7 +676,7 @@ namespace build2 if (u) { - phase_ = n; + ctx_.phase = n; r = !fail_; // Notify others that could be waiting for this phase. @@ -691,11 +689,11 @@ namespace build2 } else // phase != n { - sched.deactivate (false /* external */); - for (; phase_ != n; v->wait (l)) ; + ctx_.sched.deactivate (false /* external */); + for (; ctx_.phase != n; v->wait (l)) ; r = !fail_; l.unlock (); // Important: activate() can block. - sched.activate (false /* external */); + ctx_.sched.activate (false /* external */); } } |