Reduce usage of std::bind()
C++14 lambdas are easier to read, easier to debug,
and can usually be better optimized by the compiler.
Change-Id: I294f275904f91942a8de946fe63e77078a7608a6
diff --git a/tests/other/face-benchmark.cpp b/tests/other/face-benchmark.cpp
index 28af8dc..1ed2143 100644
--- a/tests/other/face-benchmark.cpp
+++ b/tests/other/face-benchmark.cpp
@@ -43,14 +43,13 @@
class FaceBenchmark
{
public:
+ explicit
FaceBenchmark(const char* configFileName)
- : m_terminationSignalSet{getGlobalIoService()}
+ : m_terminationSignalSet{getGlobalIoService(), SIGINT, SIGTERM}
, m_tcpChannel{tcp::Endpoint{boost::asio::ip::tcp::v4(), 6363}, false,
- bind([] { return ndn::nfd::FACE_SCOPE_NON_LOCAL; })}
+ [] (auto&&...) { return ndn::nfd::FACE_SCOPE_NON_LOCAL; }}
, m_udpChannel{udp::Endpoint{boost::asio::ip::udp::v4(), 6363}, 10_min, false, ndn::MAX_NDN_PACKET_SIZE}
{
- m_terminationSignalSet.add(SIGINT);
- m_terminationSignalSet.add(SIGTERM);
m_terminationSignalSet.async_wait([] (const auto& error, int) {
if (!error)
getGlobalIoService().stop();
@@ -58,12 +57,12 @@
parseConfig(configFileName);
- m_tcpChannel.listen(bind(&FaceBenchmark::onLeftFaceCreated, this, _1),
- bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
+ m_tcpChannel.listen(std::bind(&FaceBenchmark::onLeftFaceCreated, this, _1),
+ std::bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
std::clog << "Listening on " << m_tcpChannel.getUri() << std::endl;
- m_udpChannel.listen(bind(&FaceBenchmark::onLeftFaceCreated, this, _1),
- bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
+ m_udpChannel.listen(std::bind(&FaceBenchmark::onLeftFaceCreated, this, _1),
+ std::bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
std::clog << "Listening on " << m_udpChannel.getUri() << std::endl;
}
@@ -86,7 +85,7 @@
std::clog << "Unsupported protocol '" << uriR.getScheme() << "'" << std::endl;
}
else {
- m_faceUris.push_back(std::make_pair(uriL, uriR));
+ m_faceUris.emplace_back(uriL, uriR);
}
}
@@ -125,13 +124,13 @@
auto port = boost::lexical_cast<uint16_t>(uriR.getPort());
if (uriR.getScheme() == "tcp4") {
m_tcpChannel.connect(tcp::Endpoint(addr, port), {},
- bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
- bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
+ std::bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
+ std::bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
}
else if (uriR.getScheme() == "udp4") {
m_udpChannel.connect(udp::Endpoint(addr, port), {},
- bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
- bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
+ std::bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
+ std::bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
}
}