Skip to content

Commit

Permalink
tools: switch to Face::getIoContext()
Browse files Browse the repository at this point in the history
Change-Id: I6be4c682d62e1061af45052d2141b9e5b9e897c5
  • Loading branch information
Pesa committed Nov 11, 2023
1 parent 9a63bf2 commit e277f8b
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 25 deletions.
6 changes: 5 additions & 1 deletion .waf-tools/default-compiler-flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ def getCompilerVersion(self, conf):

def getGeneralFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
return {
'CXXFLAGS': [],
'LINKFLAGS': [],
'DEFINES': ['BOOST_FILESYSTEM_NO_DEPRECATED'],
}

def getDebugFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
Expand Down
4 changes: 2 additions & 2 deletions README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The simplest way to run the tests is to launch the compiled binary without any p
# Run NFD RIB management tests
./build/unit-tests-rib

The [Boost.Test framework](https://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/index.html)
The [Boost.Test framework](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/index.html)
is very flexible and allows a number of run-time customization of what tests should be run.
For example, it is possible to choose to run only a specific test suite, only a specific
test case within a suite, or specific test cases within specific test suites:
Expand Down Expand Up @@ -92,4 +92,4 @@ or `-p` to show a progress bar:

There are many more command line options available, information about which can be obtained
either from the command line using the `--help` switch, or online on the
[Boost.Test website](https://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/index.html).
[Boost.Test website](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/runtime_config.html).
2 changes: 1 addition & 1 deletion tests/daemon/mgmt/rib-manager.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class RibManagerFixture : public ManagerCommonFixture
data->setContent(resp.wireEncode());
m_keyChain.sign(*data, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_SHA256));

boost::asio::post(m_face.getIoService(), [this, data] { m_face.receive(*data); });
boost::asio::post(m_face.getIoContext(), [this, data] { m_face.receive(*data); });
};

const Name commandPrefix("/localhost/nfd/fib/add-nexthop");
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/ndn-autoconfig-server/program.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(RoutablePrefixesDataset)
}
this->initialize(options);

DummyClientFace clientFace(face.getIoService());
DummyClientFace clientFace(face.getIoContext());
clientFace.linkTo(face);

Name baseName("/localhop/nfd/rib/routable-prefixes");
Expand Down
13 changes: 7 additions & 6 deletions tests/tools/ndn-autoconfig/procedure.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ class DummyStage : public Stage
boost::asio::io_context& m_io;
};

/** \brief Two-stage Procedure where the first stage succeeds and the second stage fails.
*
* But the second stage shouldn't be invoked after the first stage succeeds.
/**
* Two-stage Procedure where the first stage succeeds and the second stage fails,
* but the second stage shouldn't be invoked after the first stage succeeds.
*/
class ProcedureSuccessFailure : public Procedure
{
public:
ProcedureSuccessFailure(Face& face, KeyChain& keyChain)
: Procedure(face, keyChain)
, m_io(face.getIoService())
, m_io(face.getIoContext())
{
}

Expand All @@ -137,14 +137,15 @@ class ProcedureSuccessFailure : public Procedure
boost::asio::io_context& m_io;
};

/** \brief Two-stage Procedure where the first stage fails and the second stage succeeds.
/**
* Two-stage Procedure where the first stage fails and the second stage succeeds.
*/
class ProcedureFailureSuccess : public Procedure
{
public:
ProcedureFailureSuccess(Face& face, KeyChain& keyChain)
: Procedure(face, keyChain)
, m_io(face.getIoService())
, m_io(face.getIoContext())
{
}

Expand Down
14 changes: 7 additions & 7 deletions tools/ndn-autoconfig/main.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -60,10 +60,10 @@ usage(std::ostream& os,
static void
runDaemon(Procedure& proc)
{
boost::asio::signal_set terminateSignals(proc.getIoService());
boost::asio::signal_set terminateSignals(proc.getIoContext());
terminateSignals.add(SIGINT);
terminateSignals.add(SIGTERM);
terminateSignals.async_wait([&] (const boost::system::error_code& error, int signalNo) {
terminateSignals.async_wait([&] (const auto& error, int signalNo) {
if (error) {
return;
}
Expand All @@ -76,10 +76,10 @@ runDaemon(Procedure& proc)
std::cerr << signalName;
}
std::cerr << std::endl;
proc.getIoService().stop();
proc.getIoContext().stop();
});

Scheduler sched(proc.getIoService());
Scheduler sched(proc.getIoContext());
scheduler::ScopedEventId runEvt;
auto scheduleRerun = [&] (time::nanoseconds delay) {
runEvt = sched.schedule(delay, [&] { proc.runOnce(); });
Expand All @@ -89,11 +89,11 @@ runDaemon(Procedure& proc)
scheduleRerun(DAEMON_UNCONDITIONAL_INTERVAL);
});

net::NetworkMonitor netmon(proc.getIoService());
net::NetworkMonitor netmon(proc.getIoContext());
netmon.onNetworkStateChanged.connect([&] { scheduleRerun(NETMON_DAMPEN_PERIOD); });

scheduleRerun(DAEMON_INITIAL_DELAY);
proc.getIoService().run();
proc.getIoContext().run();
}

static int
Expand Down
4 changes: 2 additions & 2 deletions tools/ndn-autoconfig/procedure.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -108,7 +108,7 @@ Procedure::connect(const FaceUri& hubFaceUri)
std::cerr << "Failed to canonize HUB FaceUri: " << reason << std::endl;
this->onComplete(false);
},
m_face.getIoService(), FACEURI_CANONIZE_TIMEOUT);
m_face.getIoContext(), FACEURI_CANONIZE_TIMEOUT);
}

void
Expand Down
7 changes: 4 additions & 3 deletions tools/ndn-autoconfig/procedure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ class Procedure : noncopyable
void
initialize(const Options& options);

/** \brief Run HUB discovery procedure once.
/**
* \brief Run the HUB discovery procedure once.
*/
void
runOnce();

boost::asio::io_context&
getIoService()
getIoContext() const noexcept
{
return m_face.getIoService();
return m_face.getIoContext();
}

private:
Expand Down
2 changes: 1 addition & 1 deletion tools/nfd-autoreg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AutoregServer : boost::noncopyable
m_faceMonitor.onNotification.connect([this] (const auto& notif) { onNotification(notif); });
m_faceMonitor.start();

boost::asio::signal_set signalSet(m_face.getIoService(), SIGINT, SIGTERM);
boost::asio::signal_set signalSet(m_face.getIoContext(), SIGINT, SIGTERM);
signalSet.async_wait([this] (auto&&...) { m_face.shutdown(); });

m_face.processEvents();
Expand Down
2 changes: 1 addition & 1 deletion tools/nfdc/face-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ canonize(ExecuteContext& ctx, const FaceUri& uri)
uri.canonize(
[&result] (const auto& canonicalUri) { result = canonicalUri; },
[&error] (const auto& errorReason) { error = errorReason; },
ctx.face.getIoService(), ctx.getTimeout());
ctx.face.getIoContext(), ctx.getTimeout());
ctx.face.processEvents();

return {result, error};
Expand Down

0 comments on commit e277f8b

Please sign in to comment.