summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/python
diff options
context:
space:
mode:
authoreb2008-08-19 23:09:56 +0000
committereb2008-08-19 23:09:56 +0000
commit2c8ea58e4d76f54c98d71d3fcc64bc29da490908 (patch)
tree2d5021474a22fcea2425903bdc288e1405701f7a /gnuradio-core/src/python
parent6039ba34aee72974b0eacc9408627a0fa038dc81 (diff)
downloadgnuradio-2c8ea58e4d76f54c98d71d3fcc64bc29da490908.tar.gz
gnuradio-2c8ea58e4d76f54c98d71d3fcc64bc29da490908.tar.bz2
gnuradio-2c8ea58e4d76f54c98d71d3fcc64bc29da490908.zip
Merged features/mp-sched -r8915:9335 into the trunk. The trunk now
contains the SMP aware scheduler. This changeset introduces a dependency on boost 1.35 or later. See source:gnuradio/trunk/README.building-boost for additional info. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9336 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/python')
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/top_block.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gr/top_block.py b/gnuradio-core/src/python/gnuradio/gr/top_block.py
index 8f5754d65..a3161170a 100644
--- a/gnuradio-core/src/python/gnuradio/gr/top_block.py
+++ b/gnuradio-core/src/python/gnuradio/gr/top_block.py
@@ -22,6 +22,33 @@
from gnuradio_swig_python import top_block_swig, \
top_block_wait_unlocked, top_block_run_unlocked
+#import gnuradio.gr.gr_threading as _threading
+import gr_threading as _threading
+
+
+#
+# There is no problem that can't be solved with an additional
+# level of indirection...
+#
+# This kludge allows ^C to interrupt top_block.run and top_block.wait
+#
+class _top_block_waiter(_threading.Thread):
+ def __init__(self, tb):
+ _threading.Thread.__init__(self)
+ self.setDaemon(1)
+ self.tb = tb
+ self.event = _threading.Event()
+ self.start()
+
+ def run(self):
+ top_block_wait_unlocked(self.tb)
+ self.event.set()
+
+ def wait(self):
+ while not self.event.isSet():
+ self.event.wait(0.100)
+
+
#
# This hack forces a 'has-a' relationship to look like an 'is-a' one.
#
@@ -48,10 +75,12 @@ class top_block(object):
self._tb.stop()
def run(self):
- top_block_run_unlocked(self._tb)
+ self.start()
+ self.wait()
def wait(self):
- top_block_wait_unlocked(self._tb)
+ _top_block_waiter(self._tb).wait()
+
# FIXME: these are duplicated from hier_block2.py; they should really be implemented
# in the original C++ class (gr_hier_block2), then they would all be inherited here