summaryrefslogtreecommitdiffstats
path: root/pym/portage/util/_eventloop/GlibEventLoop.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-02-09 12:04:42 -0800
committerZac Medico <zmedico@gentoo.org>2012-02-09 12:04:42 -0800
commit56337b00ea46d96037037816d7b5c7904825b8a9 (patch)
tree1f4c78f0571dcf2feab17030e4ccdd987839bff5 /pym/portage/util/_eventloop/GlibEventLoop.py
parent7a6c34cc6bd6eb20a97e05347f87a0157f4ae58a (diff)
downloadportage-56337b00ea46d96037037816d7b5c7904825b8a9.tar.gz
portage-56337b00ea46d96037037816d7b5c7904825b8a9.tar.bz2
portage-56337b00ea46d96037037816d7b5c7904825b8a9.zip
Add global_event_loop() and GlibEventLoop.
This causes all PollScheduler instances within a given process to share a singleton EventLoop instance, and also makes it possible to swap in glib's main loop for all portage event loops in the main process.
Diffstat (limited to 'pym/portage/util/_eventloop/GlibEventLoop.py')
-rw-r--r--pym/portage/util/_eventloop/GlibEventLoop.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/pym/portage/util/_eventloop/GlibEventLoop.py b/pym/portage/util/_eventloop/GlibEventLoop.py
new file mode 100644
index 000000000..b35772e7f
--- /dev/null
+++ b/pym/portage/util/_eventloop/GlibEventLoop.py
@@ -0,0 +1,20 @@
+# Copyright 2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import portage
+portage.proxy.lazyimport.lazyimport(globals(),
+ 'glib',
+)
+
+class GlibEventLoop(object):
+
+ # TODO: Support multiprocessing by using a separate glib.MainContext
+ # instance for each process.
+ supports_multiprocessing = False
+
+ def __init__(self):
+ self.iteration = glib.main_context_default().iteration
+ self.idle_add = glib.idle_add
+ self.io_add_watch = glib.io_add_watch
+ self.timeout_add = glib.timeout_add
+ self.source_remove = glib.source_remove