build: require boost >= 1.71.0
Refs: #5276
Change-Id: Ie428541639dcf1113acfb9e9d0a80f9be87d6cd3
diff --git a/daemon/common/global.cpp b/daemon/common/global.cpp
index c54f043..a9848cd 100644
--- a/daemon/common/global.cpp
+++ b/daemon/common/global.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,18 +27,18 @@
namespace nfd {
-static thread_local unique_ptr<boost::asio::io_service> g_ioService;
+static thread_local unique_ptr<boost::asio::io_context> g_ioCtx;
static thread_local unique_ptr<Scheduler> g_scheduler;
-static boost::asio::io_service* g_mainIoService = nullptr;
-static boost::asio::io_service* g_ribIoService = nullptr;
+static boost::asio::io_context* g_mainIoCtx = nullptr;
+static boost::asio::io_context* g_ribIoCtx = nullptr;
-boost::asio::io_service&
+boost::asio::io_context&
getGlobalIoService()
{
- if (g_ioService == nullptr) {
- g_ioService = make_unique<boost::asio::io_service>();
+ if (g_ioCtx == nullptr) {
+ g_ioCtx = make_unique<boost::asio::io_context>();
}
- return *g_ioService;
+ return *g_ioCtx;
}
Scheduler&
@@ -55,46 +55,34 @@
resetGlobalIoService()
{
g_scheduler.reset();
- g_ioService.reset();
+ g_ioCtx.reset();
}
#endif
-boost::asio::io_service&
+boost::asio::io_context&
getMainIoService()
{
- BOOST_ASSERT(g_mainIoService != nullptr);
- return *g_mainIoService;
+ BOOST_ASSERT(g_mainIoCtx != nullptr);
+ return *g_mainIoCtx;
}
-boost::asio::io_service&
+boost::asio::io_context&
getRibIoService()
{
- BOOST_ASSERT(g_ribIoService != nullptr);
- return *g_ribIoService;
+ BOOST_ASSERT(g_ribIoCtx != nullptr);
+ return *g_ribIoCtx;
}
void
-setMainIoService(boost::asio::io_service* mainIo)
+setMainIoService(boost::asio::io_context* mainIo)
{
- g_mainIoService = mainIo;
+ g_mainIoCtx = mainIo;
}
void
-setRibIoService(boost::asio::io_service* ribIo)
+setRibIoService(boost::asio::io_context* ribIo)
{
- g_ribIoService = ribIo;
-}
-
-void
-runOnMainIoService(const std::function<void()>& f)
-{
- getMainIoService().post(f);
-}
-
-void
-runOnRibIoService(const std::function<void()>& f)
-{
- getRibIoService().post(f);
+ g_ribIoCtx = ribIo;
}
} // namespace nfd
diff --git a/daemon/common/global.hpp b/daemon/common/global.hpp
index 25102f9..3ee072d 100644
--- a/daemon/common/global.hpp
+++ b/daemon/common/global.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022 Regents of the University of California,
+ * Copyright (c) 2014-2023 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,46 +27,39 @@
#include "core/common.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
namespace nfd {
-/** \brief Returns the global io_service instance for the calling thread.
+/**
+ * \brief Returns the global io_context instance for the calling thread.
*/
-boost::asio::io_service&
+boost::asio::io_context&
getGlobalIoService();
-/** \brief Returns the global Scheduler instance for the calling thread.
+/**
+ * \brief Returns the global Scheduler instance for the calling thread.
*/
Scheduler&
getScheduler();
-boost::asio::io_service&
+boost::asio::io_context&
getMainIoService();
-boost::asio::io_service&
+boost::asio::io_context&
getRibIoService();
void
-setMainIoService(boost::asio::io_service* mainIo);
+setMainIoService(boost::asio::io_context* mainIo);
void
-setRibIoService(boost::asio::io_service* ribIo);
-
-/** \brief Run a function on the main io_service instance.
- */
-void
-runOnMainIoService(const std::function<void()>& f);
-
-/** \brief Run a function on the RIB io_service instance.
- */
-void
-runOnRibIoService(const std::function<void()>& f);
+setRibIoService(boost::asio::io_context* ribIo);
#ifdef NFD_WITH_TESTS
-/** \brief Destroy the global io_service instance.
+/**
+ * \brief Destroy the global io_context instance.
*
- * It will be recreated at the next invocation of getGlobalIoService().
+ * It will be recreated at the next invocation of getGlobalIoService().
*/
void
resetGlobalIoService();
diff --git a/daemon/face/tcp-transport.cpp b/daemon/face/tcp-transport.cpp
index 0332c2f..45bc952 100644
--- a/daemon/face/tcp-transport.cpp
+++ b/daemon/face/tcp-transport.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -128,13 +128,7 @@
BOOST_ASSERT(getState() == TransportState::DOWN);
// recreate the socket
- m_socket = protocol::socket(
-#if BOOST_VERSION >= 107000
- m_socket.get_executor()
-#else
- m_socket.get_io_service()
-#endif // BOOST_VERSION >= 107000
- );
+ m_socket = protocol::socket(m_socket.get_executor());
this->resetReceiveBuffer();
this->resetSendQueue();
diff --git a/daemon/fw/self-learning-strategy.cpp b/daemon/fw/self-learning-strategy.cpp
index 19d9d75..acf1f22 100644
--- a/daemon/fw/self-learning-strategy.cpp
+++ b/daemon/fw/self-learning-strategy.cpp
@@ -34,6 +34,7 @@
#include <ndn-cxx/lp/prefix-announcement-header.hpp>
#include <ndn-cxx/lp/tags.hpp>
+#include <boost/asio/post.hpp>
#include <boost/range/adaptor/reversed.hpp>
namespace nfd::fw {
@@ -188,26 +189,28 @@
// (the PIT entry's expiry timer was set to 0 before dispatching)
this->setExpiryTimer(pitEntry, 1_s);
- runOnRibIoService([this, pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data] {
- rib::Service::get().getRibManager().slFindAnn(data.getName(),
- [this, pitEntryWeak, inFaceId, data] (std::optional<ndn::PrefixAnnouncement> paOpt) {
- if (paOpt) {
- runOnMainIoService([this, pitEntryWeak, inFaceId, data, pa = std::move(*paOpt)] {
- auto pitEntry = pitEntryWeak.lock();
- auto inFace = this->getFace(inFaceId);
- if (pitEntry && inFace) {
- NFD_LOG_DEBUG("Found PrefixAnnouncement=" << pa.getAnnouncedName());
- data.setTag(make_shared<lp::PrefixAnnouncementTag>(lp::PrefixAnnouncementHeader(pa)));
- this->sendDataToAll(data, pitEntry, *inFace);
- this->setExpiryTimer(pitEntry, 0_ms);
- }
- else {
- NFD_LOG_DEBUG("PIT entry or face no longer exists");
- }
- });
- }
+ boost::asio::post(getRibIoService(),
+ [this, pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data] {
+ rib::Service::get().getRibManager().slFindAnn(data.getName(),
+ [this, pitEntryWeak, inFaceId, data] (std::optional<ndn::PrefixAnnouncement> paOpt) {
+ if (paOpt) {
+ boost::asio::post(getMainIoService(),
+ [this, pitEntryWeak, inFaceId, data, pa = std::move(*paOpt)] {
+ auto pitEntry = pitEntryWeak.lock();
+ auto inFace = this->getFace(inFaceId);
+ if (pitEntry && inFace) {
+ NFD_LOG_DEBUG("Found PrefixAnnouncement=" << pa.getAnnouncedName());
+ data.setTag(make_shared<lp::PrefixAnnouncementTag>(lp::PrefixAnnouncementHeader(pa)));
+ this->sendDataToAll(data, pitEntry, *inFace);
+ this->setExpiryTimer(pitEntry, 0_ms);
+ }
+ else {
+ NFD_LOG_DEBUG("PIT entry or face no longer exists");
+ }
+ });
+ }
+ });
});
- });
}
bool
@@ -235,24 +238,26 @@
SelfLearningStrategy::addRoute(const shared_ptr<pit::Entry>& pitEntry, const Face& inFace,
const Data& data, const ndn::PrefixAnnouncement& pa)
{
- runOnRibIoService([pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data, pa] {
- rib::Service::get().getRibManager().slAnnounce(pa, inFaceId, ROUTE_RENEW_LIFETIME,
- [] (RibManager::SlAnnounceResult res) {
- NFD_LOG_DEBUG("Add route via PrefixAnnouncement with result=" << res);
- });
- });
+ boost::asio::post(getRibIoService(),
+ [pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data, pa] {
+ rib::Service::get().getRibManager().slAnnounce(pa, inFaceId, ROUTE_RENEW_LIFETIME,
+ [] (RibManager::SlAnnounceResult res) {
+ NFD_LOG_DEBUG("Add route via PrefixAnnouncement with result=" << res);
+ });
+ });
}
void
SelfLearningStrategy::renewRoute(const Name& name, FaceId inFaceId, time::milliseconds maxLifetime)
{
// renew route with PA or ignore PA (if route has no PA)
- runOnRibIoService([name, inFaceId, maxLifetime] {
- rib::Service::get().getRibManager().slRenew(name, inFaceId, maxLifetime,
- [] (RibManager::SlAnnounceResult res) {
- NFD_LOG_DEBUG("Renew route with result=" << res);
- });
- });
+ boost::asio::post(getRibIoService(),
+ [name, inFaceId, maxLifetime] {
+ rib::Service::get().getRibManager().slRenew(name, inFaceId, maxLifetime,
+ [] (RibManager::SlAnnounceResult res) {
+ NFD_LOG_DEBUG("Renew route with result=" << res);
+ });
+ });
}
} // namespace nfd::fw
diff --git a/daemon/main.cpp b/daemon/main.cpp
index 60a589a..bfaba73 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -70,7 +70,7 @@
/** \brief Executes NFD with RIB manager
*
* NFD (main forwarding procedure) and RIB manager execute in two different threads.
- * Each thread has its own instances of global io_service and global scheduler.
+ * Each thread has its own instances of global io_context and global scheduler.
*
* When either of the daemons fails, execution of non-failed daemon will be terminated as
* well. In other words, when NFD fails, RIB manager will be terminated; when RIB manager
@@ -107,9 +107,9 @@
// a separate thread) fails.
std::atomic_int retval(0);
- boost::asio::io_service* const mainIo = &getGlobalIoService();
+ boost::asio::io_context* const mainIo = &getGlobalIoService();
setMainIoService(mainIo);
- boost::asio::io_service* ribIo = nullptr;
+ boost::asio::io_context* ribIo = nullptr;
// Mutex and conditional variable to implement synchronization between main and RIB manager
// threads:
diff --git a/daemon/rib/service.hpp b/daemon/rib/service.hpp
index 3cedde4..0d0aa07 100644
--- a/daemon/rib/service.hpp
+++ b/daemon/rib/service.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -46,7 +46,7 @@
* \brief Initializes and executes the NFD-RIB service thread.
*
* Only one instance of this class can be created at any time.
- * After initialization, NFD-RIB instance can be started by running the global io_service.
+ * After initialization, NFD-RIB instance can be started by running the global io_context.
*/
class Service : noncopyable
{