aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scheduler.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-05-13 09:02:17 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-05-13 09:02:17 +0200
commitad9cdb9b172ecd7acf5e55b60f3f77626d72f14f (patch)
treebf26ce2bad2efdae443a03cbe7874621f4dc31cc /libbuild2/scheduler.cxx
parenta77a968800ba36cb04fb58c73e768f5ec137b45c (diff)
Do lazy allocation of shadow task queues
Diffstat (limited to 'libbuild2/scheduler.cxx')
-rw-r--r--libbuild2/scheduler.cxx12
1 files changed, 5 insertions, 7 deletions
diff --git a/libbuild2/scheduler.cxx b/libbuild2/scheduler.cxx
index 8c0ea17..bdd703d 100644
--- a/libbuild2/scheduler.cxx
+++ b/libbuild2/scheduler.cxx
@@ -571,7 +571,8 @@ namespace build2
// phase helpers. The way we are going to do it is to temporarily (until
// pop) replace such queues with empty ones. This should be ok since a
// thread with such a "shadowed" queue won't wake up until we return to
- // the old phase.
+ // the old phase (but the shadow queue may be used if the thread in
+ // question is also switching to the new phase).
//
// Note also that the assumption here is that while we may still have
// "phase-less" threads milling around (e.g., transitioning from active to
@@ -589,13 +590,10 @@ namespace build2
if (tq.size != 0)
{
- queued_task_count_.fetch_sub (tq.size, memory_order_release);
-
- // @@ TODO: should we make task_queue::data allocation lazy? On the
- // other hand, we don't seem to get many non-empty queues here on
- // real-world projects.
+ // Note that task_queue::data will be allocated lazily (there is a
+ // good chance this queue is not going to be used in the new phase).
//
- j->data.reset (new task_data[task_queue_depth_]);
+ queued_task_count_.fetch_sub (tq.size, memory_order_release);
tq.swap (*j);
}
}