From 2c8ea58e4d76f54c98d71d3fcc64bc29da490908 Mon Sep 17 00:00:00 2001 From: eb Date: Tue, 19 Aug 2008 23:09:56 +0000 Subject: 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 --- gnuradio-core/src/python/gnuradio/gr/top_block.py | 33 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'gnuradio-core/src/python') 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 -- cgit