summaryrefslogtreecommitdiffstats
path: root/pym/portage/util/_async
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-10-05 13:48:53 -0700
committerZac Medico <zmedico@gentoo.org>2012-10-05 13:48:53 -0700
commite4b64dd7dc7c2217055f110990b2496b71976681 (patch)
tree9cfccd57286d0013556dc470cad9e3a54bde38ad /pym/portage/util/_async
parente58829dd5e2272b9c3878cd0ec92680fae075b40 (diff)
downloadportage-e4b64dd7dc7c2217055f110990b2496b71976681.tar.gz
portage-e4b64dd7dc7c2217055f110990b2496b71976681.tar.bz2
portage-e4b64dd7dc7c2217055f110990b2496b71976681.zip
TaskScheduler: inherit AsyncScheduler
This allows the QueueScheduler class to be eliminated.
Diffstat (limited to 'pym/portage/util/_async')
-rw-r--r--pym/portage/util/_async/TaskScheduler.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/pym/portage/util/_async/TaskScheduler.py b/pym/portage/util/_async/TaskScheduler.py
new file mode 100644
index 000000000..b0ec7af09
--- /dev/null
+++ b/pym/portage/util/_async/TaskScheduler.py
@@ -0,0 +1,22 @@
+# Copyright 2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from .AsyncScheduler import AsyncScheduler
+
+class TaskScheduler(AsyncScheduler):
+
+ __slots__ = ('_task_iter',)
+
+ """
+ A simple way to handle scheduling of AbstractPollTask instances. Simply
+ pass a task iterator into the constructor and call start(). Use the
+ poll, wait, or addExitListener methods to be notified when all of the
+ tasks have completed.
+ """
+
+ def __init__(self, task_iter, **kwargs):
+ AsyncScheduler.__init__(self, **kwargs)
+ self._task_iter = task_iter
+
+ def _next_task(self):
+ return next(self._task_iter)