aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/context.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-08-22 14:38:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-08-23 18:14:07 +0200
commit5035f4ef68922ac758b1e4734e67d73c9228010b (patch)
tree271fdd5b1d6e995a058d97aacb3ac90a538d9ff1 /libbuild2/context.ixx
parent8793941652d6aa1c3d02b2f87f691e6d06254b7d (diff)
Introduce notion of build context
All non-const global state is now in class context and we can now have multiple independent builds going on at the same time.
Diffstat (limited to 'libbuild2/context.ixx')
-rw-r--r--libbuild2/context.ixx20
1 files changed, 12 insertions, 8 deletions
diff --git a/libbuild2/context.ixx b/libbuild2/context.ixx
index f947bd7..7fb85ad 100644
--- a/libbuild2/context.ixx
+++ b/libbuild2/context.ixx
@@ -8,19 +8,19 @@ namespace build2
//
inline wait_guard::
wait_guard ()
- : start_count (0), task_count (nullptr), phase (false)
+ : ctx (nullptr), start_count (0), task_count (nullptr), phase (false)
{
}
inline wait_guard::
- wait_guard (atomic_count& tc, bool p)
- : wait_guard (0, tc, p)
+ wait_guard (context& c, atomic_count& tc, bool p)
+ : wait_guard (c, 0, tc, p)
{
}
inline wait_guard::
- wait_guard (size_t sc, atomic_count& tc, bool p)
- : start_count (sc), task_count (&tc), phase (p)
+ wait_guard (context& c, size_t sc, atomic_count& tc, bool p)
+ : ctx (&c), start_count (sc), task_count (&tc), phase (p)
{
}
@@ -33,7 +33,10 @@ namespace build2
inline wait_guard::
wait_guard (wait_guard&& x)
- : start_count (x.start_count), task_count (x.task_count), phase (x.phase)
+ : ctx (x.ctx),
+ start_count (x.start_count),
+ task_count (x.task_count),
+ phase (x.phase)
{
x.task_count = nullptr;
}
@@ -44,6 +47,7 @@ namespace build2
if (&x != this)
{
assert (task_count == nullptr);
+ ctx = x.ctx;
start_count = x.start_count; task_count = x.task_count; phase = x.phase;
x.task_count = nullptr;
}
@@ -53,8 +57,8 @@ namespace build2
inline void wait_guard::
wait ()
{
- phase_unlock u (phase);
- sched.wait (start_count, *task_count);
+ phase_unlock u (*ctx, phase);
+ ctx->sched.wait (start_count, *task_count);
task_count = nullptr;
}
}