diff options
Diffstat (limited to 'gnuradio-core/src/lib/runtime/gr_runtime.i')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_runtime.i | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_runtime.i b/gnuradio-core/src/lib/runtime/gr_runtime.i index 2933c7187..3a8b7e0b6 100644 --- a/gnuradio-core/src/lib/runtime/gr_runtime.i +++ b/gnuradio-core/src/lib/runtime/gr_runtime.i @@ -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(); +} + +%} |