diff options
author | jcorgan | 2009-07-10 01:26:37 +0000 |
---|---|---|
committer | jcorgan | 2009-07-10 01:26:37 +0000 |
commit | a9154607d6f6fd2bfbafd732dccf9edef35e1e6e (patch) | |
tree | 39d76114da110de5269a340cab2c651410d7637d /gr-wxgui/src/python/common.py | |
parent | e921d54419e95c097cdecf21a2de7c393eb75f18 (diff) | |
download | gnuradio-a9154607d6f6fd2bfbafd732dccf9edef35e1e6e.tar.gz gnuradio-a9154607d6f6fd2bfbafd732dccf9edef35e1e6e.tar.bz2 gnuradio-a9154607d6f6fd2bfbafd732dccf9edef35e1e6e.zip |
Refactor msgq thread classes to use gru.msgq_runner
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11407 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-wxgui/src/python/common.py')
-rw-r--r-- | gr-wxgui/src/python/common.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/src/python/common.py index c6b9509b2..d555a1f05 100644 --- a/gr-wxgui/src/python/common.py +++ b/gr-wxgui/src/python/common.py @@ -44,31 +44,26 @@ def register_access_methods(destination, controller): ################################################## # Input Watcher Thread ################################################## -import threading +from gnuradio import gru -class input_watcher(threading.Thread): +class input_watcher(gru.msgq_runner): """ Input watcher thread runs forever. Read messages from the message queue. Forward messages to the message handler. """ def __init__ (self, msgq, controller, msg_key, arg1_key='', arg2_key=''): - threading.Thread.__init__(self) - self.setDaemon(1) - self.msgq = msgq self._controller = controller self._msg_key = msg_key self._arg1_key = arg1_key self._arg2_key = arg2_key - self.keep_running = True - self.start() + gru.msgq_runner.__init__(self, msgq, self.handle_msg) + + def handle_msg(self, msg): + if self._arg1_key: self._controller[self._arg1_key] = msg.arg1() + if self._arg2_key: self._controller[self._arg2_key] = msg.arg2() + self._controller[self._msg_key] = msg.to_string() - def run(self): - while self.keep_running: - msg = self.msgq.delete_head() - if self._arg1_key: self._controller[self._arg1_key] = msg.arg1() - if self._arg2_key: self._controller[self._arg2_key] = msg.arg2() - self._controller[self._msg_key] = msg.to_string() ################################################## # Shared Functions |