aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/context.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-22 14:32:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-22 14:32:49 +0200
commitdf69d473d3ab389e915698b8c2c4bb8d22975976 (patch)
tree3f624b109e8a91bb99aa649489f9a548ba088ddf /libbuild2/context.hxx
parent5483f5f54146ef6486db93a9a1c45b967d59c384 (diff)
Implement loaded_modules state locking
This would be necessary if someone runs two parallel top-level contexts.
Diffstat (limited to 'libbuild2/context.hxx')
-rw-r--r--libbuild2/context.hxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx
index 60f5ba8..0a2deea 100644
--- a/libbuild2/context.hxx
+++ b/libbuild2/context.hxx
@@ -40,6 +40,8 @@ namespace build2
struct opspec;
+ struct loaded_modules_lock;
+
class LIBBUILD2_SYMEXPORT run_phase_mutex
{
public:
@@ -129,6 +131,11 @@ namespace build2
// future we can do save/restore but then we would need some indication that
// we have switched to another task).
//
+ // The loaded_modules state (module.hxx) is shared among all the contexts
+ // (there is no way to have multiple shared library loading "contexts") and
+ // is protected by loaded_modules_lock. A nested context should normally
+ // inherit this lock value from its outer context.
+ //
// Note also that any given thread should not participate in multiple
// schedulers at the same time (see scheduler::join/leave() for details).
//
@@ -414,6 +421,10 @@ namespace build2
dir_path old_src_root;
dir_path new_src_root;
+ // NULL if this context hasn't already locked the loaded_modules state.
+ //
+ const loaded_modules_lock* modules_lock;
+
// Nested context for updating build system modules.
//
// Note that such a context itself should normally have modules_context
@@ -434,7 +445,8 @@ namespace build2
bool dry_run = false,
bool keep_going = true,
const strings& cmd_vars = {},
- optional<context*> module_context = nullptr);
+ optional<context*> module_context = nullptr,
+ const loaded_modules_lock* inherited_mudules_lock = nullptr);
// Set current meta-operation and operation.
//