From b47a323f09f1f9ccece03ca4d84dbe7a47ff8177 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Oct 2019 10:02:23 +0200 Subject: Move global mutex shards to context --- libbuild2/context.hxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libbuild2/context.hxx') diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx index d2e38e7..cc34803 100644 --- a/libbuild2/context.hxx +++ b/libbuild2/context.hxx @@ -99,6 +99,18 @@ namespace build2 mutex lm_; }; + class global_mutex_shards + { + public: + size_t variable_cache_size; + unique_ptr variable_cache; + + explicit + global_mutex_shards (size_t vc) + : variable_cache_size (vc), + variable_cache (new shared_mutex[variable_cache_size]) {} + }; + // @@ CTX: document (backlinks, non-overlap etc). RW story. // // A context can be preempted to execute another context (we do this, for @@ -122,6 +134,7 @@ namespace build2 public: scheduler& sched; + global_mutex_shards& mutex_shards; // Dry run flag (see --dry-run|-n). // @@ -412,6 +425,7 @@ namespace build2 // explicit context (scheduler&, + global_mutex_shards&, bool dry_run = false, bool keep_going = true, const strings& cmd_vars = {}, -- cgit v1.1