]> git.gag.com Git - debian/gnuradio/commitdiff
Merge jcorgan/sfg changeset 4089 into trunk.
authorjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Thu, 14 Dec 2006 23:37:20 +0000 (23:37 +0000)
committerjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Thu, 14 Dec 2006 23:37:20 +0000 (23:37 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4090 221aa14e-8319-0410-a670-987f0aec2ac5

gnuradio-core/src/lib/runtime/gr_runtime.i
gnuradio-core/src/python/gnuradio/gr/hier_block2.py
gnuradio-core/src/python/gnuradio/gr/qa_runtime.py

index 2933c71871cb43aa9da8db9637385b7d6c576cb9..3a8b7e0b6e634a27a48161cb3427de4e2c5859bc 100644 (file)
@@ -37,3 +37,39 @@ public:
     void stop() throw (std::runtime_error);
     void wait() throw (std::runtime_error);
 };
+
+%{
+class ensure_py_gil_state2 {
+    PyGILState_STATE   d_gstate;
+public:
+  ensure_py_gil_state2()  { d_gstate = PyGILState_Ensure(); }
+  ~ensure_py_gil_state2() { PyGILState_Release(d_gstate); }
+};
+%}
+
+%inline %{
+void runtime_run_unlocked(gr_runtime_sptr r) throw (std::runtime_error) 
+{
+    ensure_py_gil_state2 _lock;
+    r->run();
+}
+
+void runtime_start_unlocked(gr_runtime_sptr r) throw (std::runtime_error) 
+{
+    ensure_py_gil_state2 _lock;
+    r->start();
+}
+
+void runtime_stop_unlocked(gr_runtime_sptr r) throw (std::runtime_error) 
+{
+    ensure_py_gil_state2 _lock;
+    r->stop();
+}
+
+void runtime_wait_unlocked(gr_runtime_sptr r) throw (std::runtime_error) 
+{
+    ensure_py_gil_state2 _lock;
+    r->wait();
+}
+
+%}
index cd185d168460368ccbd274488375637f7c5ed6ec..5877401b55367eaacf15dfc90e2014fd59e5eb60 100644 (file)
@@ -19,7 +19,9 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-from gnuradio_swig_python import hier_block2_swig, gr_make_runtime 
+from gnuradio_swig_python import hier_block2_swig, gr_make_runtime, \
+    runtime_run_unlocked, runtime_start_unlocked, runtime_stop_unlocked, \
+    runtime_wait_unlocked 
 
 #
 # This hack forces a 'has-a' relationship to look like an 'is-a' one.
@@ -47,4 +49,13 @@ class runtime(object):
             self._r = gr_make_runtime(top_block)
 
     def run(self):
-        self._r.run()
+        runtime_run_unlocked(self._r)
+
+    def start(self):
+        runtime_start_unlocked(self._r)
+
+    def stop(self):
+        runtime_stop_unlocked(self._r)
+
+    def wait(self):
+        runtime_wait_unlocked(self._r)
index 1951afa8e3b3f17ac24443aa1814c8c6f20bdb8a..ce0bdde21275967c8802051734e371598231791a 100755 (executable)
@@ -11,19 +11,19 @@ class test_runtime(gr_unittest.TestCase):
        pass
 
     def test_001_run(self):
-       hblock = gr.hier_block2("test_block", 
+       hblock = gr.hier_block2("test_block", 
                                gr.io_signature(0,0,0), 
                                gr.io_signature(0,0,0))
-       runtime = gr.runtime(hblock)
-       runtime.run()
+       runtime = gr.runtime(hblock)
+       runtime.run()
 
     def test_002_run_twice(self):
-       hblock = gr.hier_block2("test_block", 
+       hblock = gr.hier_block2("test_block", 
                                gr.io_signature(0,0,0), 
                                gr.io_signature(0,0,0))
-       runtime = gr.runtime(hblock)
-       runtime.run()
-       self.assertRaises(RuntimeError, lambda: runtime.run())
+       runtime = gr.runtime(hblock)
+       runtime.run()
+       self.assertRaises(RuntimeError, lambda: runtime.run())
         
 if __name__ == "__main__":
     gr_unittest.main()