aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-10-10 07:20:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-10-10 07:20:49 +0200
commit9f95a23eae04680559a9cb943fdfaa00f52cd66e (patch)
treece65f5257e129a30781f8221982257de3b343903
parent66e7100be28e6758b65592120f47e1965301c12d (diff)
Use term shared instead of global for scope, var pool, etc
-rw-r--r--libbuild2/scope.cxx6
-rw-r--r--libbuild2/scope.hxx4
-rw-r--r--libbuild2/variable.cxx14
-rw-r--r--libbuild2/variable.hxx38
4 files changed, 32 insertions, 30 deletions
diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx
index 814d876..74f212e 100644
--- a/libbuild2/scope.cxx
+++ b/libbuild2/scope.cxx
@@ -32,8 +32,8 @@ namespace build2
// scope
//
scope::
- scope (context& c, bool global)
- : ctx (c), vars (c, global), target_vars (c, global)
+ scope (context& c, bool shared)
+ : ctx (c), vars (c, shared), target_vars (c, shared)
{
}
@@ -1028,7 +1028,7 @@ namespace build2
if (er.first->second.front () == nullptr)
{
- er.first->second.front () = new scope (ctx, true /* global */);
+ er.first->second.front () = new scope (ctx, true /* shared */);
er.second = true;
}
diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx
index 36bbc81..2105512 100644
--- a/libbuild2/scope.hxx
+++ b/libbuild2/scope.hxx
@@ -606,7 +606,7 @@ namespace build2
friend LIBBUILD2_SYMEXPORT scope& create_bootstrap_inner (scope&,
const dir_path&);
- scope (context&, bool global);
+ scope (context&, bool shared);
~scope ();
// Return true if this root scope can be amalgamated.
@@ -698,7 +698,7 @@ namespace build2
{
public:
temp_scope (scope& p)
- : scope (p.ctx, false /* global */)
+ : scope (p.ctx, false /* shared */)
{
out_path_ = p.out_path_;
src_path_ = p.src_path_;
diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx
index 9cdad0b..9e98bb6 100644
--- a/libbuild2/variable.cxx
+++ b/libbuild2/variable.cxx
@@ -1710,7 +1710,7 @@ namespace build2
const bool* o,
bool pat)
{
- assert (!global_ || global_->phase == run_phase::load);
+ assert (!shared_ || shared_->phase == run_phase::load);
// Apply pattern.
//
@@ -1804,7 +1804,7 @@ namespace build2
bool retro,
bool match)
{
- assert (!global_ || global_->phase == run_phase::load);
+ assert (!shared_ || shared_->phase == run_phase::load);
size_t pn (p.size ());
@@ -1922,7 +1922,7 @@ namespace build2
pair<value&, bool> variable_map::
insert (const variable& var, bool typed, bool reset_extra)
{
- assert (!global_ || ctx->phase == run_phase::load);
+ assert (!shared_ || ctx->phase == run_phase::load);
auto p (m_.emplace (var, value_data (typed ? var.type : nullptr)));
value_data& r (p.first->second);
@@ -1934,7 +1934,7 @@ namespace build2
// Check if this is the first access after being assigned a type.
//
- // Note: we still need atomic in case this is not a global state.
+ // Note: we still need atomic in case this is not a shared state.
//
if (typed && var.type != nullptr)
typify (r, var);
@@ -1948,7 +1948,7 @@ namespace build2
bool variable_map::
erase (const variable& var)
{
- assert (!global_ || ctx->phase == run_phase::load);
+ assert (!shared_ || ctx->phase == run_phase::load);
return m_.erase (var) != 0;
}
@@ -1956,7 +1956,7 @@ namespace build2
variable_map::const_iterator variable_map::
erase (const_iterator i)
{
- assert (!global_ || ctx->phase == run_phase::load);
+ assert (!shared_ || ctx->phase == run_phase::load);
return const_iterator (m_.erase (i), *this);
}
@@ -1967,7 +1967,7 @@ namespace build2
insert (pattern_type type, string&& text)
{
auto r (map_.emplace (pattern {type, false, move (text), {}},
- variable_map (ctx, global_)));
+ variable_map (ctx, shared_)));
// Compile the regex.
//
diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx
index c03838f..4f87818 100644
--- a/libbuild2/variable.hxx
+++ b/libbuild2/variable.hxx
@@ -1231,7 +1231,8 @@ namespace build2
// Variable pool.
//
- // The global (as in, context-wide) version is protected by the phase mutex.
+ // The shared versions (as in, context or project-wide) are protected by the
+ // phase mutex and thus can only be modified during the load phase.
//
class variable_pool
{
@@ -1405,12 +1406,12 @@ namespace build2
public:
variable_pool (): variable_pool (nullptr) {}
- // RW access (only for the global pool).
+ // RW access (only for shared pools).
//
variable_pool&
rw () const
{
- assert (global_->phase == run_phase::load);
+ assert (shared_->phase == run_phase::load);
return const_cast<variable_pool&> (*this);
}
@@ -1492,15 +1493,15 @@ namespace build2
private:
multiset<pattern> patterns_;
- // Global pool flag/context.
+ // Shared pool flag/context.
//
private:
friend class context;
explicit
- variable_pool (context* global): global_ (global) {}
+ variable_pool (context* shared): shared_ (shared) {}
- context* global_;
+ context* shared_;
};
}
@@ -1710,12 +1711,13 @@ namespace build2
size () const {return m_.size ();}
public:
- // Global should be true if this map is part of the global build state
- // (e.g., scopes, etc).
+ // Shared should be true if this map is part of the shared build state
+ // (e.g., scopes, etc) and thus should only be modified during the load
+ // phase.
//
explicit
- variable_map (context& c, bool global = false)
- : ctx (&c), global_ (global) {}
+ variable_map (context& c, bool shared = false)
+ : ctx (&c), shared_ (shared) {}
void
clear () {m_.clear ();}
@@ -1735,7 +1737,7 @@ namespace build2
private:
context* ctx;
map_type m_;
- bool global_;
+ bool shared_;
};
LIBBUILD2_SYMEXPORT extern const variable_map empty_variable_map;
@@ -1868,8 +1870,8 @@ namespace build2
using const_iterator = map_type::const_iterator;
using const_reverse_iterator = map_type::const_reverse_iterator;
- variable_pattern_map (context& c, bool global)
- : ctx (c), global_ (global) {}
+ variable_pattern_map (context& c, bool shared)
+ : ctx (c), shared_ (shared) {}
// Note that here we assume the "outer" pattern format (delimiters, flags,
// etc) is valid.
@@ -1885,7 +1887,7 @@ namespace build2
operator[] (string text)
{
return map_.emplace (pattern {pattern_type::path, false, move (text), {}},
- variable_map (ctx, global_)).first->second;
+ variable_map (ctx, shared_)).first->second;
}
const_iterator begin () const {return map_.begin ();}
@@ -1897,7 +1899,7 @@ namespace build2
private:
context& ctx;
map_type map_;
- bool global_;
+ bool shared_;
};
class LIBBUILD2_SYMEXPORT variable_type_map
@@ -1907,13 +1909,13 @@ namespace build2
variable_pattern_map>;
using const_iterator = map_type::const_iterator;
- variable_type_map (context& c, bool global): ctx (c), global_ (global) {}
+ variable_type_map (context& c, bool shared): ctx (c), shared_ (shared) {}
variable_pattern_map&
operator[] (const target_type& t)
{
return map_.emplace (
- t, variable_pattern_map (ctx, global_)).first->second;
+ t, variable_pattern_map (ctx, shared_)).first->second;
}
const_iterator begin () const {return map_.begin ();}
@@ -1943,7 +1945,7 @@ namespace build2
private:
context& ctx;
map_type map_;
- bool global_;
+ bool shared_;
};
}