From 145589cf2b524b59a8ffa950882d3433e2885b7c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Mar 2022 11:13:05 +0200 Subject: Rename execute_wait() to execute() The old half-way semantics of execute() wasn't useful. --- libbuild2/algorithm.cxx | 5 ++++- libbuild2/algorithm.hxx | 21 +++++++-------------- libbuild2/algorithm.ixx | 23 ++++++++++++----------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index c101117..64d4689 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -2510,7 +2510,10 @@ namespace build2 // const target& g (*t.group); - target_state gs (execute (a, g)); + // This is execute(a, t, false) but that saves a call to executed_state() + // (which we don't need). + // + target_state gs (execute (a, g, 0, nullptr)); if (gs == target_state::busy) ctx.sched.wait (ctx.count_executed (), diff --git a/libbuild2/algorithm.hxx b/libbuild2/algorithm.hxx index f6c296e..b472603 100644 --- a/libbuild2/algorithm.hxx +++ b/libbuild2/algorithm.hxx @@ -537,27 +537,20 @@ namespace build2 // Execute the action on target, assuming a rule has been matched and the // recipe for this action has been set. This is the synchrounous executor - // implementation (but may still return target_state::busy if the target - // is already being executed). Decrements the dependents count. - // - // Note: does not translate target_state::failed to the failed exception. - // - target_state - execute (action, const target&); - - // As above but wait for completion if the target is busy and translate - // target_state::failed to the failed exception. + // implementation that waits for completion if the target is already being + // executed. Translate target_state::failed to the failed exception unless + // fail is false. // target_state - execute_wait (action, const target&); + execute (action, const target&, bool fail = true); // As above but start asynchronous execution. Return target_state::unknown // if the asynchrounous execution has been started and target_state::busy if // the target has already been busy. // - // If fail is false, then return target_state::failed if the target match - // failed. Otherwise, throw the failed exception if keep_going is false and - // return target_state::failed otherwise. + // If fail is false, then return target_state::failed if the target + // execution failed. Otherwise, throw the failed exception if keep_going is + // false and return target_state::failed otherwise. // target_state execute_async (action, const target&, diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx index 29a4b59..c57e117 100644 --- a/libbuild2/algorithm.ixx +++ b/libbuild2/algorithm.ixx @@ -680,22 +680,23 @@ namespace build2 execute (action, const target&, size_t, atomic_count*); inline target_state - execute (action a, const target& t) + execute (action a, const target& t, bool fail) { - return execute (a, t, 0, nullptr); - } - - inline target_state - execute_wait (action a, const target& t) - { - //@@ redo + target_state r (execute (a, t, 0, nullptr)); - if (execute (a, t) == target_state::busy) + if (r == target_state::busy) + { t.ctx.sched.wait (t.ctx.count_executed (), t[a].task_count, scheduler::work_none); - return t.executed_state (a); + r = t.executed_state (a, false); + } + + if (r == target_state::failed && fail) + throw failed (); + + return r; } inline target_state @@ -757,7 +758,7 @@ namespace build2 execute_inner (action a, const target& t) { assert (a.outer ()); - return execute_wait (a.inner_action (), t); + return execute (a.inner_action (), t); } inline target_state -- cgit v1.1