summaryrefslogtreecommitdiff
path: root/distbuild/mainloop.py
diff options
context:
space:
mode:
Diffstat (limited to 'distbuild/mainloop.py')
-rw-r--r--distbuild/mainloop.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/distbuild/mainloop.py b/distbuild/mainloop.py
index f0e5eebc..e7c0cc3b 100644
--- a/distbuild/mainloop.py
+++ b/distbuild/mainloop.py
@@ -1,6 +1,6 @@
# mainloop/mainloop.py -- select-based main loop
#
-# Copyright (C) 2012, 2014 Codethink Limited
+# Copyright (C) 2012, 2014-2015 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -12,8 +12,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA..
+# with this program. If not, see <http://www.gnu.org/licenses/>.
import fcntl
@@ -56,7 +55,13 @@ class MainLoop(object):
def remove_state_machine(self, machine):
logging.debug('MainLoop.remove_state_machine: %s' % machine)
self._machines.remove(machine)
-
+
+ def state_machines_of_type(self, machine_type):
+ return [m for m in self._machines if isinstance(m, machine_type)]
+
+ def n_state_machines_of_type(self, machine_type):
+ return len(self.state_machines_of_type(machine_type))
+
def add_event_source(self, event_source):
logging.debug('MainLoop.add_event_source: %s' % event_source)
self._sources.append(event_source)