SequentialTaskQueue: schedule automatically
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Feb 2012 00:33:14 +0000 (16:33 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Feb 2012 00:33:14 +0000 (16:33 -0800)
This is needed to compensate for the removal of _idle_schedule in
commit 8c1fcf5a9ba9fa4d406a4d0cc284fe73a84f5a63, so that the
Scheduler's task queues operate without needing their schedule methods
called inside Scheduler._schedule_tasks().

pym/_emerge/Scheduler.py
pym/_emerge/SequentialTaskQueue.py

index ee7a02ca3c48c3e557c9018a123610a05152c874..d3f77611d07b2d234b423d393402daa1fdaccdfb 100644 (file)
@@ -1514,6 +1514,8 @@ class Scheduler(PollScheduler):
 
                while True:
 
+                       state_change = 0
+
                        # When the number of jobs and merges drops to zero,
                        # process a single merge from _merge_wait_queue if
                        # it's not empty. We only process one since these are
@@ -1524,17 +1526,15 @@ class Scheduler(PollScheduler):
                                not self._task_queues.merge):
                                task = self._merge_wait_queue.popleft()
                                task.addExitListener(self._merge_wait_exit_handler)
+                               self._merge_wait_scheduled.append(task)
                                self._task_queues.merge.add(task)
                                self._status_display.merges = len(self._task_queues.merge)
-                               self._merge_wait_scheduled.append(task)
+                               state_change += 1
 
-                       self._schedule_tasks_imp()
-                       self._status_display.display()
+                       if self._schedule_tasks_imp():
+                               state_change += 1
 
-                       state_change = 0
-                       for q in self._task_queues.values():
-                               if q.schedule():
-                                       state_change += 1
+                       self._status_display.display()
 
                        # Cancel prefetchers if they're the only reason
                        # the main poll loop is still running.
index c1c98c411cd14e47c3945aa068842723b77c64f5..88ac844d95a3107c16c24bb538741690a71446da 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import sys
@@ -20,10 +20,12 @@ class SequentialTaskQueue(SlotObject):
        def add(self, task):
                self._task_queue.append(task)
                self._dirty = True
+               self.schedule()
 
        def addFront(self, task):
                self._task_queue.appendleft(task)
                self._dirty = True
+               self.schedule()
 
        def schedule(self):
 
@@ -69,6 +71,7 @@ class SequentialTaskQueue(SlotObject):
                self.running_tasks.remove(task)
                if self._task_queue:
                        self._dirty = True
+                       self.schedule()
 
        def clear(self):
                self._task_queue.clear()