From 0a1f06d11edb1d48fd8c848348031bf08652a580 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 4 Oct 2023 12:43:06 +0200 Subject: Add match_direct_complete() to support async direct matches --- libbuild2/algorithm.hxx | 17 +++++++++++------ libbuild2/algorithm.ixx | 32 +++++++++++++++++++------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/libbuild2/algorithm.hxx b/libbuild2/algorithm.hxx index 7cc42c2..dedfe33 100644 --- a/libbuild2/algorithm.hxx +++ b/libbuild2/algorithm.hxx @@ -383,12 +383,6 @@ namespace build2 LIBBUILD2_SYMEXPORT void match_only_sync (action, const target&); - // As above but without incrementing the target's dependents count. Should - // be executed with execute_direct_*(). - // - target_state - match_direct_sync (action, const target&, bool fail = true); - // Start asynchronous match. Return target_state::postponed if the // asynchronous operation has been started and target_state::busy if the // target has already been busy. Regardless of the result, match_complete() @@ -410,6 +404,17 @@ namespace build2 pair match_complete (action, const target&, unmatch); + // As above but without incrementing the target's dependents count. Should + // be executed with execute_direct_*(). + // + // For async, call match_async() followed by match_direct_complete(). + // + target_state + match_direct_sync (action, const target&, bool fail = true); + + target_state + match_direct_complete (action, const target&, bool fail = true); + // Apply the specified recipe directly and without incrementing the // dependency counts. The target must be locked. // diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx index 9f1b70f..6d83984 100644 --- a/libbuild2/algorithm.ixx +++ b/libbuild2/algorithm.ixx @@ -427,19 +427,6 @@ namespace build2 return r; } - inline target_state - match_direct_sync (action a, const target& t, bool fail) - { - assert (t.ctx.phase == run_phase::match); - - target_state r (match_impl (a, t, 0, nullptr).second); - - if (r == target_state::failed && fail) - throw failed (); - - return r; - } - inline pair try_match_sync (action a, const target& t, bool fail) { @@ -530,6 +517,25 @@ namespace build2 return match_sync (a, t, um); } + inline target_state + match_direct_sync (action a, const target& t, bool fail) + { + assert (t.ctx.phase == run_phase::match); + + target_state r (match_impl (a, t, 0, nullptr).second); + + if (r == target_state::failed && fail) + throw failed (); + + return r; + } + + inline target_state + match_direct_complete (action a, const target& t, bool fail) + { + return match_direct_sync (a, t, fail); + } + // Clear rule match-specific target data. // inline void -- cgit v1.1