aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scheduler.ixx
diff options
context:
space:
mode:
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_;
+ }
+ }
+}