summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-18 15:18:43 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-18 15:18:43 +0900
commit494fdd65ac25cbc806fe9a369f31c595abf344e7 (patch)
treebb0f04f138ca1f1f44ff39b6f6eb08d8c3a32dee /buildstream
parent6a4949c2949ac8680de2fce11946f74ea3749a23 (diff)
downloadbuildstream-494fdd65ac25cbc806fe9a369f31c595abf344e7.tar.gz
_scheduler: Adding Queue.dequeue_ready() to avoid peeking into private queue data
And micro-optimizing the scheduler use a generator expression with any() to check the result instead of creating a list.
Diffstat (limited to 'buildstream')
-rw-r--r--buildstream/_scheduler/queue.py3
-rw-r--r--buildstream/_scheduler/scheduler.py2
2 files changed, 4 insertions, 1 deletions
diff --git a/buildstream/_scheduler/queue.py b/buildstream/_scheduler/queue.py
index 6aa12af1c..d5f2fd216 100644
--- a/buildstream/_scheduler/queue.py
+++ b/buildstream/_scheduler/queue.py
@@ -176,6 +176,9 @@ class Queue():
while self.done_queue:
yield self.done_queue.popleft()
+ def dequeue_ready(self):
+ return any(self.done_queue)
+
def process_ready(self):
scheduler = self.scheduler
unready = []
diff --git a/buildstream/_scheduler/scheduler.py b/buildstream/_scheduler/scheduler.py
index 84f538f3d..01df0996b 100644
--- a/buildstream/_scheduler/scheduler.py
+++ b/buildstream/_scheduler/scheduler.py
@@ -345,7 +345,7 @@ class Scheduler():
# process_ready() may have skipped jobs, adding them to the done_queue.
# Pull these skipped elements forward to the next queue and process them.
- process_queues = sum([len(q.done_queue) for q in self.queues]) > 0
+ process_queues = any(q.dequeue_ready() for q in self.queues)
# If nothings ticking, time to bail out
ticking = 0