aboutsummaryrefslogtreecommitdiff
path: root/build2/scheduler
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-03-14 14:12:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-03-14 14:12:01 +0200
commit0275a8661dce5b89960d2baf6245bf08679fb596 (patch)
tree2f471e1528ea144c184abce0a6f3376aa344db82 /build2/scheduler
parent233255f0e14f364841751755958375fe27380ba6 (diff)
Fix scheduler bug
Diffstat (limited to 'build2/scheduler')
-rw-r--r--build2/scheduler11
1 files changed, 8 insertions, 3 deletions
diff --git a/build2/scheduler b/build2/scheduler
index cfccefe..a8f81cd 100644
--- a/build2/scheduler
+++ b/build2/scheduler
@@ -463,6 +463,7 @@ namespace build2
{
size_t& s (tq.size);
size_t& t (tq.tail);
+ size_t& m (tq.mark);
if (s != task_queue_depth_)
{
@@ -470,6 +471,10 @@ namespace build2
// | | |
t = s != 0 ? (t != task_queue_depth_ - 1 ? t + 1 : 0) : t;
s++;
+
+ if (m == task_queue_depth_) // Enable the mark if first push.
+ m = t;
+
queued_task_count_.fetch_add (1, std::memory_order_release);
return &tq.data[t];
}
@@ -523,11 +528,11 @@ namespace build2
task_data& td (tq.data[t]);
- // Save the old queue mark and set the new one in case the task we are
- // about to run adds sub-tasks.
+ // Save the old queue mark and disable it in case the task we are about
+ // to run adds sub-tasks. The first push(), if any, will reset it.
//
size_t om (m);
- m = t; // Where next push() will go.
+ m = task_queue_depth_;
// normal wrap empty
// | | |