aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scheduler.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-01-13 12:48:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-01-13 12:48:42 +0200
commitf91dcce80beb48bf8b444b472f4820a4ff2b33e5 (patch)
tree20a81c7a939ae09a7a3fb1db7d34cbe62537acf8 /libbuild2/scheduler.ixx
parente21f9ae1a3e36160259a449e06ff52692e58b28c (diff)
Make sure we don't work any existing tasks when building in module context
Diffstat (limited to 'libbuild2/scheduler.ixx')
-rw-r--r--libbuild2/scheduler.ixx33
1 files changed, 33 insertions, 0 deletions
diff --git a/libbuild2/scheduler.ixx b/libbuild2/scheduler.ixx
new file mode 100644
index 0000000..f9f0f2e
--- /dev/null
+++ b/libbuild2/scheduler.ixx
@@ -0,0 +1,33 @@
+// file : libbuild2/scheduler.ixx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+namespace build2
+{
+ inline scheduler::queue_mark::
+ queue_mark (scheduler& s)
+ : tq_ (s.queue ())
+ {
+ if (tq_ != nullptr)
+ {
+ lock ql (tq_->mutex);
+
+ if (tq_->mark != s.task_queue_depth_)
+ {
+ om_ = tq_->mark;
+ tq_->mark = s.task_queue_depth_;
+ }
+ else
+ tq_ = nullptr;
+ }
+ }
+
+ inline scheduler::queue_mark::
+ ~queue_mark ()
+ {
+ if (tq_ != nullptr)
+ {
+ lock ql (tq_->mutex);
+ tq_->mark = tq_->size == 0 ? tq_->tail : om_;
+ }
+ }
+}