daemon: use asio::defer() instead of asio::post() where appropriate
Change-Id: I24d0fab6499d6430dd500ca157daa87f48960d15
diff --git a/tests/daemon/face/tcp-channel-fixture.hpp b/tests/daemon/face/tcp-channel-fixture.hpp
index b6eb99c..557eeb8 100644
--- a/tests/daemon/face/tcp-channel-fixture.hpp
+++ b/tests/daemon/face/tcp-channel-fixture.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,
@@ -31,6 +31,8 @@
#include "channel-fixture.hpp"
+#include <boost/asio/defer.hpp>
+
namespace nfd::tests {
using face::TcpChannel;
@@ -57,7 +59,7 @@
void
connect(TcpChannel& channel) final
{
- g_io.post([&] {
+ boost::asio::defer(g_io, [&] {
channel.connect(listenerEp, {},
[this] (const shared_ptr<Face>& newFace) {
BOOST_REQUIRE(newFace != nullptr);
diff --git a/tests/daemon/face/udp-channel-fixture.hpp b/tests/daemon/face/udp-channel-fixture.hpp
index a314a8c..63caf9a 100644
--- a/tests/daemon/face/udp-channel-fixture.hpp
+++ b/tests/daemon/face/udp-channel-fixture.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,
@@ -31,6 +31,8 @@
#include "channel-fixture.hpp"
+#include <boost/asio/defer.hpp>
+
namespace nfd::tests {
using face::UdpChannel;
@@ -52,7 +54,7 @@
void
connect(UdpChannel& channel) final
{
- g_io.post([&] {
+ boost::asio::defer(g_io, [&] {
channel.connect(listenerEp, {},
[this] (const shared_ptr<Face>& newFace) {
BOOST_REQUIRE(newFace != nullptr);
diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp
index 8ae96ae..0b407f6 100644
--- a/tests/daemon/mgmt/rib-manager.t.cpp
+++ b/tests/daemon/mgmt/rib-manager.t.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,
@@ -185,7 +185,7 @@
data->setContent(resp.wireEncode());
m_keyChain.sign(*data, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_SHA256));
- m_face.getIoService().post([this, data] { m_face.receive(*data); });
+ boost::asio::post(m_face.getIoService(), [this, data] { m_face.receive(*data); });
};
const Name commandPrefix("/localhost/nfd/fib/add-nexthop");
diff --git a/tests/daemon/rib/fib-updates-common.hpp b/tests/daemon/rib/fib-updates-common.hpp
index 33b549d..15e623f 100644
--- a/tests/daemon/rib/fib-updates-common.hpp
+++ b/tests/daemon/rib/fib-updates-common.hpp
@@ -33,6 +33,8 @@
#include "tests/daemon/global-io-fixture.hpp"
#include "tests/daemon/rib/create-route.hpp"
+#include <boost/asio/defer.hpp>
+
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace nfd::tests {
@@ -80,7 +82,7 @@
uint32_t nTimeouts)
{
updates.push_back(update);
- getGlobalIoService().post([=] {
+ boost::asio::defer(getGlobalIoService(), [=] {
if (mockSuccess) {
onUpdateSuccess(update, onSuccess, onFailure);
}
diff --git a/tests/tools/mock-nfd-mgmt-fixture.hpp b/tests/tools/mock-nfd-mgmt-fixture.hpp
index ede5568..eed9846 100644
--- a/tests/tools/mock-nfd-mgmt-fixture.hpp
+++ b/tests/tools/mock-nfd-mgmt-fixture.hpp
@@ -34,6 +34,7 @@
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
+#include <boost/asio/defer.hpp>
#include <boost/concept/assert.hpp>
namespace nfd::tests {
@@ -52,7 +53,7 @@
{
face.onSendInterest.connect([this] (const Interest& interest) {
if (processInterest) {
- m_io.post([=] { processInterest(interest); });
+ boost::asio::defer(m_io, [=] { processInterest(interest); });
}
});
}