summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/top_block_impl.cc
diff options
context:
space:
mode:
authorScott Torborg <storborg@gmail.com>2018-07-14 18:56:50 -0700
committerMartin Braun <martin.braun@ettus.com>2020-01-05 16:07:47 -0800
commitb0a26eeb4d8a4e0233f30e7137ec4c13391ca2b1 (patch)
tree625ceabd8dbd7f5e5061309ce6e7a3fe543f1181 /gnuradio-runtime/lib/top_block_impl.cc
parent0c579fba83d55e2ee4acc8362a1be2beae86ad56 (diff)
Add a top_block parameter to control exception handling
This restores past behavior where the scheduler catches exceptions raised in block threads, allowing flowgraphs to continue running after the failure of an individual block. It also adds optional new behavior, selected by setting catch_exceptions=False to the top block, which causes exceptions to not be caught. In this mode of operation, a std::terminate handler can be installed to print a stack trace before the flowgraph exits.
Diffstat (limited to 'gnuradio-runtime/lib/top_block_impl.cc')
-rw-r--r--gnuradio-runtime/lib/top_block_impl.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/gnuradio-runtime/lib/top_block_impl.cc b/gnuradio-runtime/lib/top_block_impl.cc
index 16acb3826d..79cb4088fd 100644
--- a/gnuradio-runtime/lib/top_block_impl.cc
+++ b/gnuradio-runtime/lib/top_block_impl.cc
@@ -40,7 +40,9 @@ namespace gr {
#define GR_TOP_BLOCK_IMPL_DEBUG 0
-typedef scheduler_sptr (*scheduler_maker)(flat_flowgraph_sptr ffg, int max_noutput_items);
+typedef scheduler_sptr (*scheduler_maker)(flat_flowgraph_sptr ffg,
+ int max_noutput_items,
+ bool catch_exceptions);
static struct scheduler_table {
const char* name;
@@ -49,7 +51,8 @@ static struct scheduler_table {
{ "TPB", scheduler_tpb::make } // first entry is default
};
-static scheduler_sptr make_scheduler(flat_flowgraph_sptr ffg, int max_noutput_items)
+static scheduler_sptr
+make_scheduler(flat_flowgraph_sptr ffg, int max_noutput_items, bool catch_exceptions)
{
static scheduler_maker factory = 0;
@@ -72,11 +75,16 @@ static scheduler_sptr make_scheduler(flat_flowgraph_sptr ffg, int max_noutput_it
}
}
}
- return factory(ffg, max_noutput_items);
+ return factory(ffg, max_noutput_items, catch_exceptions);
}
-top_block_impl::top_block_impl(top_block* owner)
- : d_owner(owner), d_ffg(), d_state(IDLE), d_lock_count(0), d_retry_wait(false)
+top_block_impl::top_block_impl(top_block* owner, bool catch_exceptions = true)
+ : d_owner(owner),
+ d_ffg(),
+ d_state(IDLE),
+ d_lock_count(0),
+ d_retry_wait(false),
+ d_catch_exceptions(catch_exceptions)
{
}
@@ -115,7 +123,7 @@ void top_block_impl::start(int max_noutput_items)
p->get_bool("PerfCounters", "export", false))
d_ffg->enable_pc_rpc();
- d_scheduler = make_scheduler(d_ffg, d_max_noutput_items);
+ d_scheduler = make_scheduler(d_ffg, d_max_noutput_items, d_catch_exceptions);
d_state = RUNNING;
}
@@ -195,7 +203,7 @@ void top_block_impl::restart()
d_ffg = new_ffg;
// Create a new scheduler to execute it
- d_scheduler = make_scheduler(d_ffg, d_max_noutput_items);
+ d_scheduler = make_scheduler(d_ffg, d_max_noutput_items, d_catch_exceptions);
d_retry_wait = true;
}