summaryrefslogtreecommitdiff
path: root/gr-blocks
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2021-03-19 22:00:09 +0100
committermormj <34754695+mormj@users.noreply.github.com>2021-03-23 06:31:20 -0400
commitad5beaeb3a050b71de128b03c61f959765483720 (patch)
tree5f7154e34e3fe298c422b224821adc72f659094a /gr-blocks
parenteccba2048c17e0ef6002cff595effb05f6795649 (diff)
blocks: message_debug: avoid refcount modification in 'hot' PMT handling
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Diffstat (limited to 'gr-blocks')
-rw-r--r--gr-blocks/lib/message_debug_impl.cc18
-rw-r--r--gr-blocks/lib/message_debug_impl.h6
2 files changed, 13 insertions, 11 deletions
diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc
index b397d7ef84..d88be2d96d 100644
--- a/gr-blocks/lib/message_debug_impl.cc
+++ b/gr-blocks/lib/message_debug_impl.cc
@@ -30,25 +30,27 @@ message_debug_impl::message_debug_impl(bool en_uvec)
d_en_uvec(en_uvec)
{
message_port_register_in(pmt::mp("print"));
- set_msg_handler(pmt::mp("print"), [this](pmt::pmt_t msg) { this->print(msg); });
+ set_msg_handler(pmt::mp("print"),
+ [this](const pmt::pmt_t& msg) { this->print(msg); });
message_port_register_in(pmt::mp("store"));
- set_msg_handler(pmt::mp("store"), [this](pmt::pmt_t msg) { this->store(msg); });
+ set_msg_handler(pmt::mp("store"),
+ [this](const pmt::pmt_t& msg) { this->store(msg); });
message_port_register_in(pmt::mp("print_pdu"));
set_msg_handler(pmt::mp("print_pdu"),
- [this](pmt::pmt_t msg) { this->print_pdu(msg); });
+ [this](const pmt::pmt_t& msg) { this->print_pdu(msg); });
}
message_debug_impl::~message_debug_impl() {}
-void message_debug_impl::print(pmt::pmt_t msg)
+void message_debug_impl::print(const pmt::pmt_t& msg)
{
std::stringstream sout;
if (pmt::is_pdu(msg)) {
- pmt::pmt_t meta = pmt::car(msg);
- pmt::pmt_t vector = pmt::cdr(msg);
+ const auto& meta = pmt::car(msg);
+ const auto& vector = pmt::cdr(msg);
sout << "***** VERBOSE PDU DEBUG PRINT ******" << std::endl
<< pmt::write_string(meta) << std::endl;
@@ -82,14 +84,14 @@ void message_debug_impl::print(pmt::pmt_t msg)
std::cout << sout.str();
}
-void message_debug_impl::store(pmt::pmt_t msg)
+void message_debug_impl::store(const pmt::pmt_t& msg)
{
gr::thread::scoped_lock guard(d_mutex);
d_messages.push_back(msg);
}
// ! DEPRECATED as of 3.10 use print() for all printing!
-void message_debug_impl::print_pdu(pmt::pmt_t pdu)
+void message_debug_impl::print_pdu(const pmt::pmt_t& pdu)
{
if (pmt::is_pdu(pdu)) {
GR_LOG_INFO(d_logger,
diff --git a/gr-blocks/lib/message_debug_impl.h b/gr-blocks/lib/message_debug_impl.h
index 2c2077a65d..5027bfe745 100644
--- a/gr-blocks/lib/message_debug_impl.h
+++ b/gr-blocks/lib/message_debug_impl.h
@@ -35,7 +35,7 @@ private:
*
* \param msg A pmt message passed from the scheduler's message handling.
*/
- void print(pmt::pmt_t msg);
+ void print(const pmt::pmt_t& msg);
/*!
* \brief PDU formatted messages received in this port are printed to stdout.
@@ -49,7 +49,7 @@ private:
*
* \param pdu A PDU message passed from the scheduler's message handling.
*/
- void print_pdu(pmt::pmt_t pdu);
+ void print_pdu(const pmt::pmt_t& pdu);
/*!
* \brief Messages received in this port are stored in a vector.
@@ -62,7 +62,7 @@ private:
*
* \param msg A pmt message passed from the scheduler's message handling.
*/
- void store(pmt::pmt_t msg);
+ void store(const pmt::pmt_t& msg);
gr::thread::mutex d_mutex;
std::vector<pmt::pmt_t> d_messages;