aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/algorithm.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-01-21 09:03:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-01-21 09:03:28 +0200
commitd2b8ba3e586a17e78b480c129bfcf24d6e05bade (patch)
tree5e823668df3d8138a0285146ad6de1c863b57c8a /libbuild2/algorithm.cxx
parent214f1f05dfb3f2ae2090e491f3dd78836076c2e0 (diff)
Add search_new() and search_new_locked() variants of search()
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r--libbuild2/algorithm.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx
index 0370626..0c8ac6f 100644
--- a/libbuild2/algorithm.cxx
+++ b/libbuild2/algorithm.cxx
@@ -88,6 +88,28 @@ namespace build2
}
const target&
+ search_new (context& ctx, const prerequisite_key& pk)
+ {
+ assert (ctx.phase == run_phase::load || ctx.phase == run_phase::match);
+
+ if (const target* pt = search_existing_target (ctx, pk))
+ return *pt;
+
+ return create_new_target (ctx, pk);
+ }
+
+ pair<target&, ulock>
+ search_new_locked (context& ctx, const prerequisite_key& pk)
+ {
+ assert (ctx.phase == run_phase::load || ctx.phase == run_phase::match);
+
+ if (const target* pt = search_existing_target (ctx, pk))
+ return {const_cast<target&> (*pt), ulock ()};
+
+ return create_new_target_locked (ctx, pk);
+ }
+
+ const target&
search (const target& t, name n, const scope& s, const target_type* tt)
{
assert (t.ctx.phase == run_phase::match);