From e4b64dd7dc7c2217055f110990b2496b71976681 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 5 Oct 2012 13:48:53 -0700 Subject: TaskScheduler: inherit AsyncScheduler This allows the QueueScheduler class to be eliminated. --- pym/portage/util/_async/TaskScheduler.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pym/portage/util/_async/TaskScheduler.py (limited to 'pym/portage/util/_async/TaskScheduler.py') 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) -- cgit v1.2.3-1-g7c22