summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/runtime/gr_runtime.cc
diff options
context:
space:
mode:
authorjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>2006-12-18 04:35:19 +0000
committerjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>2006-12-18 04:35:19 +0000
commit95144e53f0285d9e5ea897348030a33c18773b60 (patch)
tree6b75ec33498b91cadf3e25ba90d9ee4970e8617d /gnuradio-core/src/lib/runtime/gr_runtime.cc
parent88c16d7192ccf1caf14c2417959ab675b1f6a79e (diff)
Merged jcorgan/sfg r4097:4124 into trunk, fixing hier_block2 threading issues.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4126 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/runtime/gr_runtime.cc')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_runtime.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_runtime.cc b/gnuradio-core/src/lib/runtime/gr_runtime.cc
index 926e878575..93f78fea85 100644
--- a/gnuradio-core/src/lib/runtime/gr_runtime.cc
+++ b/gnuradio-core/src/lib/runtime/gr_runtime.cc
@@ -26,8 +26,11 @@
#include <gr_runtime.h>
#include <gr_runtime_impl.h>
+#include <gr_local_sighandler.h>
#include <iostream>
+static gr_runtime *s_runtime = 0;
+
gr_runtime_sptr
gr_make_runtime(gr_hier_block2_sptr top_block)
{
@@ -37,16 +40,29 @@ gr_make_runtime(gr_hier_block2_sptr top_block)
gr_runtime::gr_runtime(gr_hier_block2_sptr top_block)
{
d_impl = new gr_runtime_impl(top_block);
+ s_runtime = this;
}
gr_runtime::~gr_runtime()
{
+ s_runtime = 0; // we don't own this
delete d_impl;
}
+// HACK: This prevents using more than one gr_runtime instance
+static void
+runtime_sigint_handler(int signum)
+{
+
+ if (s_runtime)
+ s_runtime->stop();
+}
+
void
gr_runtime::start()
{
+ gr_local_sighandler sigint(SIGINT, runtime_sigint_handler);
+
d_impl->start();
}
@@ -59,12 +75,16 @@ gr_runtime::stop()
void
gr_runtime::wait()
{
+ gr_local_sighandler sigint(SIGINT, runtime_sigint_handler);
+
d_impl->wait();
}
void
gr_runtime::run()
{
- start();
- wait();
+ gr_local_sighandler sigint(SIGINT, runtime_sigint_handler);
+
+ d_impl->start();
+ d_impl->wait();
}