diff options
author | Johannes Demel <demel@ant.uni-bremen.de> | 2020-05-02 15:36:51 +0200 |
---|---|---|
committer | Josh Morman <mormjb@gmail.com> | 2020-06-04 10:05:48 -0400 |
commit | a6a1954f83478aff0c4fc53d0e8f51b49d51cc1e (patch) | |
tree | 933ed1043c7c379e7d3f220aae96fdccd052c1fe | |
parent | 3165f73d7c6224523957fa69beade6069efea6ef (diff) |
msg_handler: Switch from boost::function to std::function
This commit is a first stab at moving from `boost::function` to `std::function`.
For now, it does only update gr-blocks. Also, this requires more testing.
If others can confirm that this change works, I'll continue to update all modules.
-rw-r--r-- | gnuradio-runtime/include/gnuradio/basic_block.h | 4 | ||||
-rw-r--r-- | gnuradio-runtime/lib/block.cc | 3 | ||||
-rw-r--r-- | gr-blocks/lib/copy_impl.cc | 3 | ||||
-rw-r--r-- | gr-blocks/lib/message_debug_impl.cc | 11 | ||||
-rw-r--r-- | gr-blocks/lib/message_strobe_impl.cc | 7 | ||||
-rw-r--r-- | gr-blocks/lib/message_strobe_random_impl.cc | 7 | ||||
-rw-r--r-- | gr-blocks/lib/multiply_matrix_impl.cc | 11 | ||||
-rw-r--r-- | gr-blocks/lib/mute_impl.cc | 5 | ||||
-rw-r--r-- | gr-blocks/lib/nop_impl.cc | 5 | ||||
-rw-r--r-- | gr-blocks/lib/pdu_filter_impl.cc | 2 | ||||
-rw-r--r-- | gr-blocks/lib/pdu_remove_impl.cc | 2 | ||||
-rw-r--r-- | gr-blocks/lib/pdu_set_impl.cc | 3 | ||||
-rw-r--r-- | gr-blocks/lib/random_pdu_impl.cc | 5 | ||||
-rw-r--r-- | gr-blocks/lib/repeat_impl.cc | 5 | ||||
-rw-r--r-- | gr-blocks/lib/socket_pdu_impl.cc | 20 | ||||
-rw-r--r-- | gr-blocks/lib/stream_pdu_base.cc | 2 | ||||
-rw-r--r-- | gr-blocks/lib/tagged_stream_multiply_length_impl.cc | 7 | ||||
-rw-r--r-- | gr-blocks/lib/tuntap_pdu_impl.cc | 3 |
18 files changed, 64 insertions, 41 deletions
diff --git a/gnuradio-runtime/include/gnuradio/basic_block.h b/gnuradio-runtime/include/gnuradio/basic_block.h index 651fda2136..47d939a5bc 100644 --- a/gnuradio-runtime/include/gnuradio/basic_block.h +++ b/gnuradio-runtime/include/gnuradio/basic_block.h @@ -18,9 +18,9 @@ #include <gnuradio/runtime_types.h> #include <gnuradio/sptr_magic.h> #include <gnuradio/thread/thread.h> -#include <boost/function.hpp> #include <boost/thread/condition_variable.hpp> #include <deque> +#include <functional> #include <map> #include <string> @@ -42,7 +42,7 @@ namespace gr { class GR_RUNTIME_API basic_block : public msg_accepter, public std::enable_shared_from_this<basic_block> { - typedef boost::function<void(pmt::pmt_t)> msg_handler_t; + typedef std::function<void(pmt::pmt_t)> msg_handler_t; private: typedef std::map<pmt::pmt_t, msg_handler_t, pmt::comparator> d_msg_handlers_t; diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc index ebfeba23ba..b10ae97072 100644 --- a/gnuradio-runtime/lib/block.cc +++ b/gnuradio-runtime/lib/block.cc @@ -49,7 +49,8 @@ block::block(const std::string& name, { global_block_registry.register_primitive(alias(), this); message_port_register_in(d_system_port); - set_msg_handler(d_system_port, boost::bind(&block::system_handler, this, _1)); + set_msg_handler(d_system_port, + std::bind(&block::system_handler, this, std::placeholders::_1)); } block::~block() { global_block_registry.unregister_primitive(symbol_name()); } diff --git a/gr-blocks/lib/copy_impl.cc b/gr-blocks/lib/copy_impl.cc index 3470756c8b..3d1229b89a 100644 --- a/gr-blocks/lib/copy_impl.cc +++ b/gr-blocks/lib/copy_impl.cc @@ -32,7 +32,8 @@ copy_impl::copy_impl(size_t itemsize) d_enabled(true) { message_port_register_in(pmt::mp("en")); - set_msg_handler(pmt::mp("en"), boost::bind(©_impl::handle_enable, this, _1)); + set_msg_handler(pmt::mp("en"), + std::bind(©_impl::handle_enable, this, std::placeholders::_1)); } copy_impl::~copy_impl() {} diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc index a9c7fbbe99..55352f6e62 100644 --- a/gr-blocks/lib/message_debug_impl.cc +++ b/gr-blocks/lib/message_debug_impl.cc @@ -78,14 +78,17 @@ message_debug_impl::message_debug_impl() : block("message_debug", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)) { message_port_register_in(pmt::mp("print")); - set_msg_handler(pmt::mp("print"), boost::bind(&message_debug_impl::print, this, _1)); + set_msg_handler(pmt::mp("print"), + std::bind(&message_debug_impl::print, this, std::placeholders::_1)); message_port_register_in(pmt::mp("store")); - set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1)); + set_msg_handler(pmt::mp("store"), + std::bind(&message_debug_impl::store, this, std::placeholders::_1)); message_port_register_in(pmt::mp("print_pdu")); - set_msg_handler(pmt::mp("print_pdu"), - boost::bind(&message_debug_impl::print_pdu, this, _1)); + set_msg_handler( + pmt::mp("print_pdu"), + std::bind(&message_debug_impl::print_pdu, this, std::placeholders::_1)); } message_debug_impl::~message_debug_impl() {} diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc index 9a601c6cb7..4f1f7b5ff9 100644 --- a/gr-blocks/lib/message_strobe_impl.cc +++ b/gr-blocks/lib/message_strobe_impl.cc @@ -41,8 +41,9 @@ message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, long period_ms) message_port_register_out(d_port); message_port_register_in(pmt::mp("set_msg")); - set_msg_handler(pmt::mp("set_msg"), - boost::bind(&message_strobe_impl::set_msg, this, _1)); + set_msg_handler( + pmt::mp("set_msg"), + std::bind(&message_strobe_impl::set_msg, this, std::placeholders::_1)); } message_strobe_impl::~message_strobe_impl() {} @@ -53,7 +54,7 @@ bool message_strobe_impl::start() // nothing breaks on concurrent access, I'll just leave it as bool. d_finished = false; d_thread = std::shared_ptr<gr::thread::thread>( - new gr::thread::thread(boost::bind(&message_strobe_impl::run, this))); + new gr::thread::thread(std::bind(&message_strobe_impl::run, this))); return block::start(); } diff --git a/gr-blocks/lib/message_strobe_random_impl.cc b/gr-blocks/lib/message_strobe_random_impl.cc index 793066c419..1241d1c382 100644 --- a/gr-blocks/lib/message_strobe_random_impl.cc +++ b/gr-blocks/lib/message_strobe_random_impl.cc @@ -51,11 +51,12 @@ message_strobe_random_impl::message_strobe_random_impl( // set up ports message_port_register_out(d_port); d_thread = std::shared_ptr<gr::thread::thread>( - new gr::thread::thread(boost::bind(&message_strobe_random_impl::run, this))); + new gr::thread::thread(std::bind(&message_strobe_random_impl::run, this))); message_port_register_in(pmt::mp("set_msg")); - set_msg_handler(pmt::mp("set_msg"), - boost::bind(&message_strobe_random_impl::set_msg, this, _1)); + set_msg_handler( + pmt::mp("set_msg"), + std::bind(&message_strobe_random_impl::set_msg, this, std::placeholders::_1)); } void message_strobe_random_impl::set_mean(float mean_ms) diff --git a/gr-blocks/lib/multiply_matrix_impl.cc b/gr-blocks/lib/multiply_matrix_impl.cc index b3452a5c17..358843abff 100644 --- a/gr-blocks/lib/multiply_matrix_impl.cc +++ b/gr-blocks/lib/multiply_matrix_impl.cc @@ -223,9 +223,10 @@ multiply_matrix_impl<gr_complex>::multiply_matrix_impl( pmt::pmt_t port_name = pmt::string_to_symbol("set_A"); message_port_register_in(port_name); - set_msg_handler( - port_name, - boost::bind(&multiply_matrix_impl<gr_complex>::msg_handler_A, this, _1)); + set_msg_handler(port_name, + std::bind(&multiply_matrix_impl<gr_complex>::msg_handler_A, + this, + std::placeholders::_1)); } template <> @@ -245,7 +246,9 @@ multiply_matrix_impl<float>::multiply_matrix_impl( pmt::pmt_t port_name = pmt::string_to_symbol("set_A"); message_port_register_in(port_name); set_msg_handler(port_name, - boost::bind(&multiply_matrix_impl<float>::msg_handler_A, this, _1)); + std::bind(&multiply_matrix_impl<float>::msg_handler_A, + this, + std::placeholders::_1)); } diff --git a/gr-blocks/lib/mute_impl.cc b/gr-blocks/lib/mute_impl.cc index f8873234bf..e77d3199b4 100644 --- a/gr-blocks/lib/mute_impl.cc +++ b/gr-blocks/lib/mute_impl.cc @@ -35,8 +35,9 @@ mute_impl<T>::mute_impl(bool mute) d_mute(mute) { this->message_port_register_in(pmt::intern("set_mute")); - this->set_msg_handler(pmt::intern("set_mute"), - boost::bind(&mute_impl<T>::set_mute_pmt, this, _1)); + this->set_msg_handler( + pmt::intern("set_mute"), + std::bind(&mute_impl<T>::set_mute_pmt, this, std::placeholders::_1)); } template <class T> diff --git a/gr-blocks/lib/nop_impl.cc b/gr-blocks/lib/nop_impl.cc index 0ae48446da..042db40da9 100644 --- a/gr-blocks/lib/nop_impl.cc +++ b/gr-blocks/lib/nop_impl.cc @@ -32,8 +32,9 @@ nop_impl::nop_impl(size_t sizeof_stream_item) { // Arrange to have count_received_msgs called when messages are received. message_port_register_in(pmt::mp("port")); - set_msg_handler(pmt::mp("port"), - boost::bind(&nop_impl::count_received_msgs, this, _1)); + set_msg_handler( + pmt::mp("port"), + std::bind(&nop_impl::count_received_msgs, this, std::placeholders::_1)); } nop_impl::~nop_impl() {} diff --git a/gr-blocks/lib/pdu_filter_impl.cc b/gr-blocks/lib/pdu_filter_impl.cc index 9924db5e87..eca057144e 100644 --- a/gr-blocks/lib/pdu_filter_impl.cc +++ b/gr-blocks/lib/pdu_filter_impl.cc @@ -33,7 +33,7 @@ pdu_filter_impl::pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert) message_port_register_out(pdu::pdu_port_id()); message_port_register_in(pdu::pdu_port_id()); set_msg_handler(pdu::pdu_port_id(), - boost::bind(&pdu_filter_impl::handle_msg, this, _1)); + std::bind(&pdu_filter_impl::handle_msg, this, std::placeholders::_1)); } void pdu_filter_impl::handle_msg(pmt::pmt_t pdu) diff --git a/gr-blocks/lib/pdu_remove_impl.cc b/gr-blocks/lib/pdu_remove_impl.cc index b68d692b94..ddcf5f995e 100644 --- a/gr-blocks/lib/pdu_remove_impl.cc +++ b/gr-blocks/lib/pdu_remove_impl.cc @@ -31,7 +31,7 @@ pdu_remove_impl::pdu_remove_impl(pmt::pmt_t k) message_port_register_out(pdu::pdu_port_id()); message_port_register_in(pdu::pdu_port_id()); set_msg_handler(pdu::pdu_port_id(), - boost::bind(&pdu_remove_impl::handle_msg, this, _1)); + std::bind(&pdu_remove_impl::handle_msg, this, std::placeholders::_1)); } void pdu_remove_impl::handle_msg(pmt::pmt_t pdu) diff --git a/gr-blocks/lib/pdu_set_impl.cc b/gr-blocks/lib/pdu_set_impl.cc index 5b25b4604c..ade302e31e 100644 --- a/gr-blocks/lib/pdu_set_impl.cc +++ b/gr-blocks/lib/pdu_set_impl.cc @@ -31,7 +31,8 @@ pdu_set_impl::pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v) { message_port_register_out(pdu::pdu_port_id()); message_port_register_in(pdu::pdu_port_id()); - set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_set_impl::handle_msg, this, _1)); + set_msg_handler(pdu::pdu_port_id(), + std::bind(&pdu_set_impl::handle_msg, this, std::placeholders::_1)); } void pdu_set_impl::handle_msg(pmt::pmt_t pdu) diff --git a/gr-blocks/lib/random_pdu_impl.cc b/gr-blocks/lib/random_pdu_impl.cc index 9a00386f0f..3714e37085 100644 --- a/gr-blocks/lib/random_pdu_impl.cc +++ b/gr-blocks/lib/random_pdu_impl.cc @@ -39,7 +39,10 @@ random_pdu_impl::random_pdu_impl(int min_items, message_port_register_out(pdu::pdu_port_id()); message_port_register_in(pmt::mp("generate")); set_msg_handler(pmt::mp("generate"), - boost::bind(&random_pdu_impl::generate_pdu, this, _1)); + std::bind(static_cast<void (random_pdu_impl::*)(pmt::pmt_t)>( + &random_pdu_impl::generate_pdu), + this, + std::placeholders::_1)); if (length_modulo < 1) throw std::runtime_error("length_module must be >= 1"); if (max_items < length_modulo) diff --git a/gr-blocks/lib/repeat_impl.cc b/gr-blocks/lib/repeat_impl.cc index b55a5f6d1d..96e2a25eb2 100644 --- a/gr-blocks/lib/repeat_impl.cc +++ b/gr-blocks/lib/repeat_impl.cc @@ -32,8 +32,9 @@ repeat_impl::repeat_impl(size_t itemsize, int interp) d_interp(interp) { message_port_register_in(pmt::mp("interpolation")); - set_msg_handler(pmt::mp("interpolation"), - boost::bind(&repeat_impl::msg_set_interpolation, this, _1)); + set_msg_handler( + pmt::mp("interpolation"), + std::bind(&repeat_impl::msg_set_interpolation, this, std::placeholders::_1)); } void repeat_impl::msg_set_interpolation(pmt::pmt_t msg) diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc index cd74d60603..14dc124e63 100644 --- a/gr-blocks/lib/socket_pdu_impl.cc +++ b/gr-blocks/lib/socket_pdu_impl.cc @@ -88,8 +88,9 @@ socket_pdu_impl::socket_pdu_impl(std::string type, start_tcp_accept(); - set_msg_handler(pdu::pdu_port_id(), - boost::bind(&socket_pdu_impl::tcp_server_send, this, _1)); + set_msg_handler( + pdu::pdu_port_id(), + std::bind(&socket_pdu_impl::tcp_server_send, this, std::placeholders::_1)); } else if (type == "TCP_CLIENT") { boost::system::error_code error = boost::asio::error::host_not_found; d_tcp_socket.reset(new boost::asio::ip::tcp::socket(d_io_service)); @@ -98,8 +99,9 @@ socket_pdu_impl::socket_pdu_impl(std::string type, throw boost::system::system_error(error); d_tcp_socket->set_option(boost::asio::ip::tcp::no_delay(d_tcp_no_delay)); - set_msg_handler(pdu::pdu_port_id(), - boost::bind(&socket_pdu_impl::tcp_client_send, this, _1)); + set_msg_handler( + pdu::pdu_port_id(), + std::bind(&socket_pdu_impl::tcp_client_send, this, std::placeholders::_1)); d_tcp_socket->async_read_some( boost::asio::buffer(d_rxbuf), @@ -118,8 +120,9 @@ socket_pdu_impl::socket_pdu_impl(std::string type, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); - set_msg_handler(pdu::pdu_port_id(), - boost::bind(&socket_pdu_impl::udp_send, this, _1)); + set_msg_handler( + pdu::pdu_port_id(), + std::bind(&socket_pdu_impl::udp_send, this, std::placeholders::_1)); } else if (type == "UDP_CLIENT") { d_udp_socket.reset( new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint)); @@ -131,8 +134,9 @@ socket_pdu_impl::socket_pdu_impl(std::string type, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); - set_msg_handler(pdu::pdu_port_id(), - boost::bind(&socket_pdu_impl::udp_send, this, _1)); + set_msg_handler( + pdu::pdu_port_id(), + std::bind(&socket_pdu_impl::udp_send, this, std::placeholders::_1)); } else throw std::runtime_error("gr::blocks:socket_pdu: unknown socket type"); diff --git a/gr-blocks/lib/stream_pdu_base.cc b/gr-blocks/lib/stream_pdu_base.cc index 988c70aca9..97e99e8886 100644 --- a/gr-blocks/lib/stream_pdu_base.cc +++ b/gr-blocks/lib/stream_pdu_base.cc @@ -44,7 +44,7 @@ void stream_pdu_base::start_rxthread(basic_block* blk, pmt::pmt_t port) { d_blk = blk; d_port = port; - d_thread = gr::thread::thread(boost::bind(&stream_pdu_base::run, this)); + d_thread = gr::thread::thread(std::bind(&stream_pdu_base::run, this)); d_started = true; } diff --git a/gr-blocks/lib/tagged_stream_multiply_length_impl.cc b/gr-blocks/lib/tagged_stream_multiply_length_impl.cc index e1c840a0d6..95877ec728 100644 --- a/gr-blocks/lib/tagged_stream_multiply_length_impl.cc +++ b/gr-blocks/lib/tagged_stream_multiply_length_impl.cc @@ -37,9 +37,10 @@ tagged_stream_multiply_length_impl::tagged_stream_multiply_length_impl( set_tag_propagation_policy(TPP_DONT); set_relative_rate(1, 1); message_port_register_in(pmt::intern("set_scalar")); - set_msg_handler( - pmt::intern("set_scalar"), - boost::bind(&tagged_stream_multiply_length_impl::set_scalar_pmt, this, _1)); + set_msg_handler(pmt::intern("set_scalar"), + std::bind(&tagged_stream_multiply_length_impl::set_scalar_pmt, + this, + std::placeholders::_1)); } tagged_stream_multiply_length_impl::~tagged_stream_multiply_length_impl() {} diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc index 058fb6d26f..17a78cc322 100644 --- a/gr-blocks/lib/tuntap_pdu_impl.cc +++ b/gr-blocks/lib/tuntap_pdu_impl.cc @@ -86,7 +86,8 @@ tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU, bool istunflag) // set up input message port message_port_register_in(pdu::pdu_port_id()); - set_msg_handler(pdu::pdu_port_id(), boost::bind(&tuntap_pdu_impl::send, this, _1)); + set_msg_handler(pdu::pdu_port_id(), + std::bind(&tuntap_pdu_impl::send, this, std::placeholders::_1)); } int tuntap_pdu_impl::tun_alloc(char* dev, int flags) |