summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
authorEric Blossom2010-11-20 16:30:43 -0800
committerEric Blossom2010-11-20 16:30:43 -0800
commit6551f537ed235bbb0ddfadb50744ea3b3fcbc2e6 (patch)
treeb75ba0a18309649f2b64f2b1f7325373ddf2bef2 /gnuradio-core/src
parent37a1e931c11f2ba0bdd8ef9ff07c6710e83c6139 (diff)
downloadgnuradio-6551f537ed235bbb0ddfadb50744ea3b3fcbc2e6.tar.gz
gnuradio-6551f537ed235bbb0ddfadb50744ea3b3fcbc2e6.tar.bz2
gnuradio-6551f537ed235bbb0ddfadb50744ea3b3fcbc2e6.zip
Add guile shim to gr_top_block::wait that exits guile mode before blocking.
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/guile/gnuradio/runtime-shim.scm13
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.i37
2 files changed, 44 insertions, 6 deletions
diff --git a/gnuradio-core/src/guile/gnuradio/runtime-shim.scm b/gnuradio-core/src/guile/gnuradio/runtime-shim.scm
index c08d3947c..105f4ddb8 100644
--- a/gnuradio-core/src/guile/gnuradio/runtime-shim.scm
+++ b/gnuradio-core/src/guile/gnuradio/runtime-shim.scm
@@ -86,4 +86,15 @@
(loop (1+ n))))))))))
-(export-safely <gr-endpoint> gr:ep gr:connect gr:disconnect)
+
+
+(define-method (gr:run (self <gr-top-block-sptr>))
+ (gr:start self)
+ (gr:wait self))
+
+(define-method (gr:wait (self <gr-top-block-sptr>))
+ ;; FIXME Set up SIGINT handling here...
+ (gr:top-block-wait-unlocked self))
+
+
+(export-safely <gr-endpoint> gr:ep gr:connect gr:disconnect gr:run gr:wait)
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i
index f18d8890b..90fa18b94 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.i
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -42,8 +42,8 @@ public:
void start() throw (std::runtime_error);
void stop();
- void wait();
- void run() throw (std::runtime_error);
+ //void wait();
+ //void run() throw (std::runtime_error);
void lock();
void unlock() throw (std::runtime_error);
void dump();
@@ -71,6 +71,33 @@ void top_block_wait_unlocked(gr_top_block_sptr r) throw (std::runtime_error)
#endif
-#ifdef SWIG_GUILE
-#warning "gr_top_block.i: top_block_run_unlocked needs to be implemented!"
+#ifdef SWIGGUILE
+
+%{
+ struct tb_arg_holder {
+ gr_top_block_sptr tb;
+ };
+
+ static void *
+ tb_wait_shim(void *arg)
+ {
+ tb_arg_holder *a = (tb_arg_holder *)arg;
+ a->tb->wait();
+ return 0;
+ }
+
+%}
+
+%inline %{
+
+ static void
+ top_block_wait_unlocked(gr_top_block_sptr r) throw (std::runtime_error)
+ {
+ tb_arg_holder a;
+ a.tb = r;
+ scm_without_guile(tb_wait_shim, (void *) &a);
+ }
+
+%}
+
#endif