summaryrefslogtreecommitdiff
blob: 56787372af0c6f758db577d432b249515204ab54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
From 591c2c16355eb065ff3f51f23d9d6026be188132 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcus=20M=C3=BCller?= <mmueller@gnuradio.org>
Date: Sat, 22 Aug 2020 14:06:22 +0200
Subject: [PATCH] msg_handler: Use lambdas in gr-uhd

---
 gr-uhd/lib/amsg_source_impl.cc |  3 +--
 gr-uhd/lib/usrp_block_impl.cc  | 10 ++++++----
 gr-uhd/lib/usrp_block_impl.h   |  1 -
 gr-uhd/lib/usrp_source_impl.cc |  6 ++++--
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/gr-uhd/lib/amsg_source_impl.cc b/gr-uhd/lib/amsg_source_impl.cc
index 46d47a5826..e1de62e028 100644
--- a/gr-uhd/lib/amsg_source_impl.cc
+++ b/gr-uhd/lib/amsg_source_impl.cc
@@ -22,7 +22,6 @@
 
 #include "amsg_source_impl.h"
 #include "gr_uhd_common.h"
-#include <boost/bind.hpp>
 
 namespace gr {
 namespace uhd {
@@ -44,7 +43,7 @@ amsg_source_impl::amsg_source_impl(const ::uhd::device_addr_t& device_addr,
     : _msgq(msgq), _running(true)
 {
     _dev = ::uhd::usrp::multi_usrp::make(device_addr);
-    _amsg_thread = gr::thread::thread(boost::bind(&amsg_source_impl::recv_loop, this));
+    _amsg_thread = gr::thread::thread([this]() { this->recv_loop(); });
 }
 
 amsg_source_impl::~amsg_source_impl()
diff --git a/gr-uhd/lib/usrp_block_impl.cc b/gr-uhd/lib/usrp_block_impl.cc
index e5e1dd9161..8344809837 100644
--- a/gr-uhd/lib/usrp_block_impl.cc
+++ b/gr-uhd/lib/usrp_block_impl.cc
@@ -21,7 +21,7 @@
  */
 
 #include "usrp_block_impl.h"
-#include <boost/make_shared.hpp>
+#include <functional>
 
 using namespace gr::uhd;
 
@@ -139,10 +139,11 @@ usrp_block_impl::usrp_block_impl(const ::uhd::device_addr_t& device_addr,
     set_msg_handler(pmt::mp("command"),
                     [this](pmt::pmt_t msg) { this->msg_handler_command(msg); });
 
-// cuz we lazy:
+    // because we're highly efficient and adverse to work
+    namespace ph = std::placeholders;
 #define REGISTER_CMD_HANDLER(key, _handler) \
-    register_msg_cmd_handler(key,           \
-                             boost::bind(&usrp_block_impl::_handler, this, _1, _2, _3))
+    register_msg_cmd_handler(               \
+        key, std::bind(&usrp_block_impl::_handler, this, ph::_1, ph::_2, ph::_3))
     // Register default command handlers:
     REGISTER_CMD_HANDLER(cmd_freq_key(), _cmd_handler_freq);
     REGISTER_CMD_HANDLER(cmd_gain_key(), _cmd_handler_gain);
@@ -153,6 +154,7 @@ usrp_block_impl::usrp_block_impl(const ::uhd::device_addr_t& device_addr,
     REGISTER_CMD_HANDLER(cmd_rate_key(), _cmd_handler_rate);
     REGISTER_CMD_HANDLER(cmd_bandwidth_key(), _cmd_handler_bw);
     REGISTER_CMD_HANDLER(cmd_antenna_key(), _cmd_handler_antenna);
+#undef REGISTER_CMD_HANDLER
 }
 
 usrp_block_impl::~usrp_block_impl()
diff --git a/gr-uhd/lib/usrp_block_impl.h b/gr-uhd/lib/usrp_block_impl.h
index 1dbc3813bd..479b7dcd65 100644
--- a/gr-uhd/lib/usrp_block_impl.h
+++ b/gr-uhd/lib/usrp_block_impl.h
@@ -26,7 +26,6 @@
 #include <gnuradio/uhd/usrp_block.h>
 #include <pmt/pmt.h>
 #include <uhd/usrp/multi_usrp.hpp>
-#include <boost/bind.hpp>
 #include <boost/dynamic_bitset.hpp>
 
 
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index a2ff0821bd..1e8ef020ab 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -57,8 +57,10 @@ usrp_source_impl::usrp_source_impl(const ::uhd::device_addr_t& device_addr,
 
     _samp_rate = this->get_samp_rate();
     _samps_per_packet = 1;
-    register_msg_cmd_handler(cmd_tag_key(),
-                             boost::bind(&usrp_source_impl::_cmd_handler_tag, this, _1));
+    register_msg_cmd_handler(
+        cmd_tag_key(), [this](const pmt::pmt_t& val, int chan, const pmt::pmt_t& msg) {
+            this->_cmd_handler_tag(val);
+        });
 }
 
 usrp_source_impl::~usrp_source_impl() {}