diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-15 03:55:15 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-02 14:03:34 +0200 |
commit | b37f1aa6398065be806e6605a023189685669885 (patch) | |
tree | b9b32091e3d70a31852302b24c99ecb62465464a /build2/cc/common | |
parent | a64b2ae2099346471ead988d5f2d383d55a9bf89 (diff) |
Implement parallel match
Diffstat (limited to 'build2/cc/common')
-rw-r--r-- | build2/cc/common | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/build2/cc/common b/build2/cc/common index c631f38..5a459b8 100644 --- a/build2/cc/common +++ b/build2/cc/common @@ -185,6 +185,7 @@ namespace build2 public: void process_libraries ( + action, const scope&, lorder, const dir_paths&, @@ -195,44 +196,70 @@ namespace build2 const function<void (const file&, const string&, bool, bool)>&, bool = false) const; - target* - search_library (const dir_paths& sysd, + const target* + search_library (action act, + const dir_paths& sysd, optional<dir_paths>& usrd, - prerequisite& p) const + const prerequisite& p) const { - if (p.target == nullptr) // First check the cache. - p.target = search_library (sysd, usrd, p.key ()); - - return p.target; + const target* r (p.target.load (memory_order_consume)); + + if (r == nullptr) + { + if ((r = search_library (act, sysd, usrd, p.key ())) != nullptr) + { + const target* e (nullptr); + if (!p.target.compare_exchange_strong ( + e, r, + memory_order_release, + memory_order_consume)) + assert (e == r); + } + } + + return r; } - private: + public: const file& - resolve_library (const scope&, + resolve_library (action, + const scope&, name, lorder, const dir_paths&, optional<dir_paths>&) const; + template <typename T> + static ulock + insert_library (T*&, + const string&, + const dir_path&, + optional<string>, + bool, + tracer&); + target* - search_library (const dir_paths&, + search_library (action, + const dir_paths&, optional<dir_paths>&, const prerequisite_key&, bool existing = false) const; const target* - search_library_existing (const dir_paths& sysd, + search_library_existing (action act, + const dir_paths& sysd, optional<dir_paths>& usrd, const prerequisite_key& pk) const { - return search_library (sysd, usrd, pk, true); + return search_library (act, sysd, usrd, pk, true); } dir_paths extract_library_dirs (const scope&) const; bool - pkgconfig_extract (const scope&, + pkgconfig_extract (action, + const scope&, bin::lib&, bin::liba*, bin::libs*, |