mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-02-07 14:40:12 +00:00
Use lambda instead of boost::bind
This commit is contained in:
parent
420db2dfd6
commit
873b1feb68
@ -103,6 +103,21 @@ if(Boost_VERSION_STRING VERSION_GREATER 1.65.99)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER 3.1)
|
||||||
|
set(has_generic_lambdas HAS_GENERIC_LAMBDA=1)
|
||||||
|
set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0)
|
||||||
|
target_compile_definitions(signal_source_gr_blocks
|
||||||
|
PRIVATE
|
||||||
|
"$<$<COMPILE_FEATURES:cxx_generic_lambdas>:${has_generic_lambdas}>"
|
||||||
|
"$<$<NOT:$<COMPILE_FEATURES:cxx_generic_lambdas>>:${no_has_generic_lambdas}>"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(signal_source_gr_blocks
|
||||||
|
PRIVATE
|
||||||
|
-DHAS_GENERIC_LAMBDA=0
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_CLANG_TIDY)
|
if(ENABLE_CLANG_TIDY)
|
||||||
if(CLANG_TIDY_EXE)
|
if(CLANG_TIDY_EXE)
|
||||||
set_target_properties(signal_source_gr_blocks
|
set_target_properties(signal_source_gr_blocks
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#if HAS_GENERIC_LAMBDA
|
||||||
|
#else
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
const int FIFO_SIZE = 1472000;
|
const int FIFO_SIZE = 1472000;
|
||||||
|
|
||||||
@ -148,7 +152,12 @@ bool Gr_Complex_Ip_Packet_Source::start()
|
|||||||
if (open() == true)
|
if (open() == true)
|
||||||
{
|
{
|
||||||
// start pcap capture thread
|
// start pcap capture thread
|
||||||
d_pcap_thread = new boost::thread(boost::bind(&Gr_Complex_Ip_Packet_Source::my_pcap_loop_thread, this, descr));
|
d_pcap_thread = new boost::thread(
|
||||||
|
#if HAS_GENERIC_LAMBDA
|
||||||
|
[this] { my_pcap_loop_thread(descr); });
|
||||||
|
#else
|
||||||
|
boost::bind(&Gr_Complex_Ip_Packet_Source::my_pcap_loop_thread, this, descr));
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
#include <boost/thread/thread.hpp>
|
#include <boost/thread/thread.hpp>
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#if HAS_GENERIC_LAMBDA
|
||||||
|
#else
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace ip = boost::asio::ip;
|
namespace ip = boost::asio::ip;
|
||||||
@ -134,9 +138,18 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
|
|||||||
|
|
||||||
// 6. Start reading
|
// 6. Start reading
|
||||||
boost::asio::async_read(socket_, boost::asio::buffer(data_),
|
boost::asio::async_read(socket_, boost::asio::buffer(data_),
|
||||||
|
#if HAS_GENERIC_LAMBDA
|
||||||
|
[this](auto &&PH1, auto &&PH2) { handle_read(PH1, PH2); });
|
||||||
|
#else
|
||||||
boost::bind(&rtl_tcp_signal_source_c::handle_read,
|
boost::bind(&rtl_tcp_signal_source_c::handle_read,
|
||||||
this, _1, _2));
|
this, _1, _2));
|
||||||
boost::thread(boost::bind(&b_io_context::run, &io_context_));
|
#endif
|
||||||
|
boost::thread(
|
||||||
|
#if HAS_GENERIC_LAMBDA
|
||||||
|
[ObjectPtr = &io_context_] { ObjectPtr->run(); });
|
||||||
|
#else
|
||||||
|
boost::bind(&b_io_context::run, &io_context_));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -288,8 +301,11 @@ void rtl_tcp_signal_source_c::handle_read(const boost::system::error_code &ec,
|
|||||||
// Unpack read data
|
// Unpack read data
|
||||||
boost::mutex::scoped_lock lock(mutex_);
|
boost::mutex::scoped_lock lock(mutex_);
|
||||||
not_full_.wait(lock,
|
not_full_.wait(lock,
|
||||||
boost::bind(&rtl_tcp_signal_source_c::not_full,
|
#if HAS_GENERIC_LAMBDA
|
||||||
this));
|
[this] { not_full(); });
|
||||||
|
#else
|
||||||
|
boost::bind(&rtl_tcp_signal_source_c::not_full, this));
|
||||||
|
#endif
|
||||||
|
|
||||||
for (size_t i = 0; i < bytes_transferred; i++)
|
for (size_t i = 0; i < bytes_transferred; i++)
|
||||||
{
|
{
|
||||||
@ -299,8 +315,11 @@ void rtl_tcp_signal_source_c::handle_read(const boost::system::error_code &ec,
|
|||||||
// wait until there's space for more
|
// wait until there's space for more
|
||||||
not_empty_.notify_one(); // needed?
|
not_empty_.notify_one(); // needed?
|
||||||
not_full_.wait(lock,
|
not_full_.wait(lock,
|
||||||
boost::bind(&rtl_tcp_signal_source_c::not_full,
|
#if HAS_GENERIC_LAMBDA
|
||||||
this));
|
[this] { not_full(); });
|
||||||
|
#else
|
||||||
|
boost::bind(&rtl_tcp_signal_source_c::not_full, this));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_.push_front(lookup_[data_[i]]);
|
buffer_.push_front(lookup_[data_[i]]);
|
||||||
@ -312,8 +331,11 @@ void rtl_tcp_signal_source_c::handle_read(const boost::system::error_code &ec,
|
|||||||
// Read some more
|
// Read some more
|
||||||
boost::asio::async_read(socket_,
|
boost::asio::async_read(socket_,
|
||||||
boost::asio::buffer(data_),
|
boost::asio::buffer(data_),
|
||||||
boost::bind(&rtl_tcp_signal_source_c::handle_read,
|
#if HAS_GENERIC_LAMBDA
|
||||||
this, _1, _2));
|
[this](auto &&PH1, auto &&PH2) { handle_read(PH1, PH2); });
|
||||||
|
#else
|
||||||
|
boost::bind(&rtl_tcp_signal_source_c::handle_read, this, _1, _2));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,9 +353,12 @@ int rtl_tcp_signal_source_c::work(int noutput_items,
|
|||||||
|
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(mutex_);
|
boost::mutex::scoped_lock lock(mutex_);
|
||||||
not_empty_.wait(lock, boost::bind(&rtl_tcp_signal_source_c::not_empty,
|
not_empty_.wait(lock,
|
||||||
this));
|
#if HAS_GENERIC_LAMBDA
|
||||||
|
[this] { not_empty(); });
|
||||||
|
#else
|
||||||
|
boost::bind(&rtl_tcp_signal_source_c::not_empty, this));
|
||||||
|
#endif
|
||||||
for (; i < noutput_items && unread_ > 1; i++)
|
for (; i < noutput_items && unread_ > 1; i++)
|
||||||
{
|
{
|
||||||
float re = buffer_[--unread_];
|
float re = buffer_[--unread_];
|
||||||
|
@ -158,7 +158,7 @@ AcqPerfTest_msg_rx::AcqPerfTest_msg_rx(Concurrent_Queue<int>& queue) : gr::block
|
|||||||
{
|
{
|
||||||
this->message_port_register_in(pmt::mp("events"));
|
this->message_port_register_in(pmt::mp("events"));
|
||||||
this->set_msg_handler(pmt::mp("events"),
|
this->set_msg_handler(pmt::mp("events"),
|
||||||
#if HAS_GENNERIC_LAMBDA
|
#if HAS_GENERIC_LAMBDA
|
||||||
[this](auto&& PH1) { msg_handler_events(PH1); });
|
[this](auto&& PH1) { msg_handler_events(PH1); });
|
||||||
#else
|
#else
|
||||||
boost::bind(&AcqPerfTest_msg_rx::msg_handler_events, this, _1));
|
boost::bind(&AcqPerfTest_msg_rx::msg_handler_events, this, _1));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user