From 53105890d75789c81adbb3d781eff9ebd7110222 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 1 Sep 2017 17:33:44 +0200 Subject: Add support for try_match(), use to handle deleted headers --- build2/target.cxx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'build2/target.cxx') diff --git a/build2/target.cxx b/build2/target.cxx index 40c73c0..7ff995d 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -117,7 +117,7 @@ namespace build2 return *r; } - target_state target:: + pair target:: state (action_type a) const { assert (phase == run_phase::match); @@ -147,15 +147,15 @@ namespace build2 for (; e == lock; e = task_count.load (memory_order_acquire)) this_thread::yield (); - if (e >= busy) - return target_state::unchanged; // Override in progress. + if (e >= busy) // Override in progress. + return make_pair (true, target_state::unchanged); // Unlike lock_impl(), we are only called after being matched for this // action so if we see executed, then it means executed for this action // (or noop). // if (e == exec) - return group_state () ? group->state_ : state_; + return make_pair (true, group_state () ? group->state_ : state_); // Try to grab the spin-lock. // @@ -174,17 +174,24 @@ namespace build2 // We have the spin-lock. Quickly get the matched action and unlock. // action_type ma (action); - bool failed (state_ == target_state::failed); + bool mf (state_ == target_state::failed); task_count.store (e, memory_order_release); if (ma > a) // Overriden. - return failed ? target_state::failed: target_state::unchanged; + return make_pair (true, // Override may have failed but we had the rule. + mf ? target_state::failed: target_state::unchanged); // Otherwise we should have a matched target. // - assert (ma == a && (e == b + target::offset_applied || e == exec)); + assert (ma == a); - return group_state () ? group->state_ : state_; + if (e == b + target::offset_tried) + return make_pair (false, target_state::unknown); + else + { + assert (e == b + target::offset_applied || e == exec); + return make_pair (true, group_state () ? group->state_ : state_); + } } pair target:: -- cgit v1.1