diff options
Diffstat (limited to 'gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h')
-rw-r--r-- | gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h b/gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h index c25aad9af4..22e5aa3015 100644 --- a/gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h +++ b/gnuradio-runtime/include/gnuradio/thread/thread_body_wrapper.h @@ -38,9 +38,13 @@ class thread_body_wrapper private: F d_f; std::string d_name; + bool d_catch_exceptions; public: - explicit thread_body_wrapper(F f, const std::string& name = "") : d_f(f), d_name(name) + explicit thread_body_wrapper(F f, + const std::string& name = "", + bool catch_exceptions = true) + : d_f(f), d_name(name), d_catch_exceptions(catch_exceptions) { } @@ -48,14 +52,25 @@ public: { mask_signals(); - try { - d_f(); - } - catch(boost::thread_interrupted const &) - { + if (d_catch_exceptions) { + try { + d_f(); + } catch (boost::thread_interrupted const&) { + } catch (std::exception const& e) { + std::cerr << "thread[" << d_name << "]: " << e.what() << std::endl; + } catch (...) { + std::cerr << "thread[" << d_name << "]: " + << "caught unrecognized exception\n"; + } + + } else { + try { + d_f(); + } catch (boost::thread_interrupted const&) { + } } - } - }; + } +}; } /* namespace thread */ } /* namespace gr */ |