commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r4090 - in gnuradio/trunk/gnuradio-core/src: lib/runti


From: jcorgan
Subject: [Commit-gnuradio] r4090 - in gnuradio/trunk/gnuradio-core/src: lib/runtime python/gnuradio/gr
Date: Thu, 14 Dec 2006 16:37:20 -0700 (MST)

Author: jcorgan
Date: 2006-12-14 16:37:20 -0700 (Thu, 14 Dec 2006)
New Revision: 4090

Modified:
   gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_runtime.i
   gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/hier_block2.py
   gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_runtime.py
Log:
Merge jcorgan/sfg changeset 4089 into trunk.

Modified: gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_runtime.i
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_runtime.i   2006-12-14 
23:35:03 UTC (rev 4089)
+++ gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_runtime.i   2006-12-14 
23:37:20 UTC (rev 4090)
@@ -37,3 +37,39 @@
     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();
+}
+
+%}

Modified: gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/hier_block2.py
===================================================================
--- gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/hier_block2.py  
2006-12-14 23:35:03 UTC (rev 4089)
+++ gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/hier_block2.py  
2006-12-14 23:37:20 UTC (rev 4090)
@@ -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 @@
             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)

Modified: gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_runtime.py
===================================================================
--- gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_runtime.py   
2006-12-14 23:35:03 UTC (rev 4089)
+++ gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_runtime.py   
2006-12-14 23:37:20 UTC (rev 4090)
@@ -11,19 +11,19 @@
        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()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]