GNU Radio Manual and C++ API Reference
3.10.5.1
The Free & Open Software Radio Ecosystem
thread_body_wrapper.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2008,2009,2013 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
7
* SPDX-License-Identifier: GPL-3.0-or-later
8
*
9
*/
10
11
#ifndef INCLUDED_THREAD_BODY_WRAPPER_H
12
#define INCLUDED_THREAD_BODY_WRAPPER_H
13
14
#include <
gnuradio/api.h
>
15
#include <
gnuradio/logger.h
>
16
#include <
gnuradio/thread/thread.h
>
17
#include <exception>
18
19
namespace
gr
{
20
namespace
thread
{
21
22
GR_RUNTIME_API
void
mask_signals
();
23
24
template
<
class
F>
25
class
thread_body_wrapper
26
{
27
private
:
28
F d_f;
29
std::string d_name;
30
bool
d_catch_exceptions;
31
gr::logger_ptr
d_logger;
32
gr::logger_ptr
d_debug_logger;
33
34
public
:
35
explicit
thread_body_wrapper
(F f,
36
const
std::string& name =
""
,
37
bool
catch_exceptions =
true
)
38
: d_f(f), d_name(name), d_catch_exceptions(catch_exceptions)
39
{
40
gr::configure_default_loggers
(d_logger, d_debug_logger,
"thread_body_wrapper"
);
41
}
42
43
void
operator()
()
44
{
45
mask_signals
();
46
47
if
(d_catch_exceptions) {
48
try
{
49
d_f();
50
}
catch
(boost::thread_interrupted
const
&) {
51
}
catch
(std::exception
const
& e) {
52
d_logger->error(
"ERROR thread[{:s}]: {:s}"
, d_name, e.what());
53
}
catch
(...) {
54
d_logger->error(
"ERROR thread[{:s}]: caught unrecognized exception"
,
55
d_name);
56
}
57
58
}
else
{
59
try
{
60
d_f();
61
}
catch
(boost::thread_interrupted
const
&) {
62
}
63
}
64
}
65
};
66
67
}
/* namespace thread */
68
}
/* namespace gr */
69
70
#endif
/* INCLUDED_THREAD_BODY_WRAPPER_H */
gr::thread::thread_body_wrapper
Definition:
thread_body_wrapper.h:26
gr::thread::thread_body_wrapper::thread_body_wrapper
thread_body_wrapper(F f, const std::string &name="", bool catch_exceptions=true)
Definition:
thread_body_wrapper.h:35
gr::thread::thread_body_wrapper::operator()
void operator()()
Definition:
thread_body_wrapper.h:43
api.h
GR_RUNTIME_API
#define GR_RUNTIME_API
Definition:
gnuradio-runtime/include/gnuradio/api.h:18
logger.h
gr::thread::thread
boost::thread thread
Definition:
thread.h:36
gr::thread::mask_signals
GR_RUNTIME_API void mask_signals()
gr
GNU Radio logging wrapper.
Definition:
basic_block.h:29
gr::logger_ptr
std::shared_ptr< logger > logger_ptr
Definition:
logger.h:225
gr::configure_default_loggers
GR_RUNTIME_API bool configure_default_loggers(gr::logger_ptr &l, gr::logger_ptr &d, const std::string &name)
thread.h
gnuradio-runtime
include
gnuradio
thread
thread_body_wrapper.h
Generated by
1.9.4