aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-22 13:03:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-22 13:03:21 +0200
commitcee00343d0c537a31281b4de74fadd7589d434b0 (patch)
treee431925cb8d77194c9ae564dedc2739030b202b7
parentbf8fd996b6651edcbb2235bbc6fae307a3638611 (diff)
Rename global_mutex_shards to global_mutexes
-rw-r--r--build2/b.cxx6
-rw-r--r--libbuild2/context.cxx4
-rw-r--r--libbuild2/context.hxx13
-rw-r--r--libbuild2/function.test.cxx4
-rw-r--r--libbuild2/module.cxx4
-rw-r--r--libbuild2/test/script/parser.test.cxx4
-rw-r--r--libbuild2/variable.cxx4
-rw-r--r--libbuild2/variable.hxx7
-rw-r--r--libbuild2/variable.txx4
-rw-r--r--tests/libbuild2/driver.cxx4
10 files changed, 29 insertions, 25 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 0183e0f..f2b7674 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -564,7 +564,7 @@ main (int argc, char* argv[])
? optional<size_t> (ops.max_stack () * 1024)
: nullopt));
- global_mutex_shards mutex_shards (sched.shard_size ());
+ global_mutexes mutexes (sched.shard_size ());
// Trace some overall environment information.
//
@@ -584,11 +584,11 @@ main (int argc, char* argv[])
// below).
//
unique_ptr<context> ctx;
- auto new_context = [&ctx, &sched, &mutex_shards, &cmd_vars]
+ auto new_context = [&ctx, &sched, &mutexes, &cmd_vars]
{
ctx = nullptr; // Free first.
ctx.reset (new context (sched,
- mutex_shards,
+ mutexes,
ops.dry_run (),
!ops.serial_stop () /* keep_going */,
cmd_vars));
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx
index 23942a8..841cc1d 100644
--- a/libbuild2/context.cxx
+++ b/libbuild2/context.cxx
@@ -56,14 +56,14 @@ namespace build2
context::
context (scheduler& s,
- global_mutex_shards& ms,
+ global_mutexes& ms,
bool dr,
bool kg,
const strings& cmd_vars,
optional<context*> mc)
: data_ (new data (*this)),
sched (s),
- mutex_shards (ms),
+ mutexes (ms),
dry_run_option (dr),
keep_going (kg),
phase_mutex (*this),
diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx
index cc34803..60f5ba8 100644
--- a/libbuild2/context.hxx
+++ b/libbuild2/context.hxx
@@ -99,14 +99,19 @@ namespace build2
mutex lm_;
};
- class global_mutex_shards
+ // Context-wide mutexes and mutex shards.
+ //
+ class global_mutexes
{
public:
+
+ // Variable cache mutex shard (see variable.hxx for details).
+ //
size_t variable_cache_size;
unique_ptr<shared_mutex[]> variable_cache;
explicit
- global_mutex_shards (size_t vc)
+ global_mutexes (size_t vc)
: variable_cache_size (vc),
variable_cache (new shared_mutex[variable_cache_size]) {}
};
@@ -134,7 +139,7 @@ namespace build2
public:
scheduler& sched;
- global_mutex_shards& mutex_shards;
+ global_mutexes& mutexes;
// Dry run flag (see --dry-run|-n).
//
@@ -425,7 +430,7 @@ namespace build2
//
explicit
context (scheduler&,
- global_mutex_shards&,
+ global_mutexes&,
bool dry_run = false,
bool keep_going = true,
const strings& cmd_vars = {},
diff --git a/libbuild2/function.test.cxx b/libbuild2/function.test.cxx
index c4f7fa2..3cf2e7c 100644
--- a/libbuild2/function.test.cxx
+++ b/libbuild2/function.test.cxx
@@ -46,8 +46,8 @@ namespace build2
// Serial execution.
//
scheduler sched (1);
- global_mutex_shards shards (1);
- context ctx (sched, shards);
+ global_mutexes mutexes (1);
+ context ctx (sched, mutexes);
auto& functions (ctx.functions);
diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx
index a55a1a6..1bd60a6 100644
--- a/libbuild2/module.cxx
+++ b/libbuild2/module.cxx
@@ -155,12 +155,12 @@ namespace build2
assert (*ctx.module_context_storage == nullptr);
// Since we are using the same scheduler, it makes sense to reuse the
- // same mutex shards. Also disable nested module context for good
+ // same global mutexes. Also disable nested module context for good
// measure.
//
ctx.module_context_storage->reset (
new context (ctx.sched,
- ctx.mutex_shards,
+ ctx.mutexes,
false, /* dry_run */
ctx.keep_going,
ctx.global_var_overrides, /* cmd_vars */
diff --git a/libbuild2/test/script/parser.test.cxx b/libbuild2/test/script/parser.test.cxx
index 2eec791..54f6ee7 100644
--- a/libbuild2/test/script/parser.test.cxx
+++ b/libbuild2/test/script/parser.test.cxx
@@ -159,8 +159,8 @@ namespace build2
// Serial execution.
//
scheduler sched (1);
- global_mutex_shards shards (1);
- context ctx (sched, shards);
+ global_mutexes mutexes (1);
+ context ctx (sched, mutexes);
bool scope (false);
bool id (false);
diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx
index 1fe9914..643a061 100644
--- a/libbuild2/variable.cxx
+++ b/libbuild2/variable.cxx
@@ -367,8 +367,8 @@ namespace build2
// Typification is kind of like caching so we reuse that mutex shard.
//
shared_mutex& m (
- ctx.mutex_shards.variable_cache[
- hash<value*> () (&v) % ctx.mutex_shards.variable_cache_size]);
+ ctx.mutexes.variable_cache[
+ hash<value*> () (&v) % ctx.mutexes.variable_cache_size]);
// Note: v.type is rechecked by typify() under lock.
//
diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx
index 29b8200..51cdf49 100644
--- a/libbuild2/variable.hxx
+++ b/libbuild2/variable.hxx
@@ -1468,10 +1468,9 @@ namespace build2
// the references remain valid).
//
// Note that since the cache can be modified on any lookup (including during
- // the execute phase), it is protected by its own mutex shard (see
- // global_mutex_shards in context). This shard is also used for value
- // typification (which is kind of like caching) during concurrent execution
- // phases.
+ // the execute phase), it is protected by its own mutex shard (see mutexes
+ // in context). This shard is also used for value typification (which is
+ // kind of like caching) during concurrent execution phases.
//
template <typename K>
class variable_cache
diff --git a/libbuild2/variable.txx b/libbuild2/variable.txx
index ed25cb6..041dc94 100644
--- a/libbuild2/variable.txx
+++ b/libbuild2/variable.txx
@@ -614,8 +614,8 @@ namespace build2
: 0);
shared_mutex& m (
- ctx.mutex_shards.variable_cache[
- hash<variable_cache*> () (this) % ctx.mutex_shards.variable_cache_size]);
+ ctx.mutexes.variable_cache[
+ hash<variable_cache*> () (this) % ctx.mutexes.variable_cache_size]);
slock sl (m);
ulock ul (m, defer_lock);
diff --git a/tests/libbuild2/driver.cxx b/tests/libbuild2/driver.cxx
index 26c00d6..d84c22a 100644
--- a/tests/libbuild2/driver.cxx
+++ b/tests/libbuild2/driver.cxx
@@ -37,8 +37,8 @@ main (int, char* argv[])
// Serial execution.
//
scheduler sched (1);
- global_mutex_shards shards (1);
- context ctx (sched, shards);
+ global_mutexes mutexes (1);
+ context ctx (sched, mutexes);
return 0;
}