From f91dcce80beb48bf8b444b472f4820a4ff2b33e5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 13 Jan 2021 12:48:42 +0200 Subject: Make sure we don't work any existing tasks when building in module context --- libbuild2/scheduler.ixx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libbuild2/scheduler.ixx (limited to 'libbuild2/scheduler.ixx') 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_; + } + } +} -- cgit v1.1