Switch to Face::getIoContext() and simplify some code
Change-Id: Iba49171f6e59ead02283e8f975219ab97fcbeb00
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 8c4033a..f135636 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -36,7 +36,7 @@
Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
: m_face(face)
- , m_scheduler(face.getIoService())
+ , m_scheduler(face.getIoContext())
, m_confParam(confParam)
, m_adjacencyList(confParam.getAdjacencyList())
, m_namePrefixList(confParam.getNamePrefixList())
@@ -259,7 +259,7 @@
Nlsr::initializeFaces(const FetchDatasetCallback& onFetchSuccess,
const FetchDatasetTimeoutCallback& onFetchFailure)
{
- NLSR_LOG_TRACE("Initializing Faces...");
+ NLSR_LOG_TRACE("Initializing faces");
m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(onFetchSuccess, onFetchFailure);
}
@@ -317,14 +317,12 @@
const std::string& msg,
uint32_t nRetriesSoFar)
{
- NLSR_LOG_DEBUG("onFaceDatasetFetchTimeout");
// If we have exceeded the maximum attempt count, do not try again.
if (nRetriesSoFar++ < m_confParam.getFaceDatasetFetchTries()) {
NLSR_LOG_DEBUG("Failed to fetch dataset: " << msg << ". Attempting retry #" << nRetriesSoFar);
- m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(std::bind(&Nlsr::processFaceDataset,
- this, _1),
- std::bind(&Nlsr::onFaceDatasetFetchTimeout,
- this, _1, _2, nRetriesSoFar));
+ m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(std::bind(&Nlsr::processFaceDataset, this, _1),
+ std::bind(&Nlsr::onFaceDatasetFetchTimeout,
+ this, _1, _2, nRetriesSoFar));
}
else {
NLSR_LOG_ERROR("Failed to fetch dataset: " << msg << ". Exceeded limit of " <<
@@ -339,17 +337,12 @@
void
Nlsr::scheduleDatasetFetch()
{
- NLSR_LOG_DEBUG("Scheduling Dataset Fetch in " << m_confParam.getFaceDatasetFetchInterval());
+ NLSR_LOG_DEBUG("Scheduling dataset fetch in " << m_confParam.getFaceDatasetFetchInterval());
- m_scheduler.schedule(m_confParam.getFaceDatasetFetchInterval(),
- [this] {
- this->initializeFaces(
- [this] (const std::vector<ndn::nfd::FaceStatus>& faces) {
- this->processFaceDataset(faces);
- },
- [this] (uint32_t code, const std::string& msg) {
- this->onFaceDatasetFetchTimeout(code, msg, 0);
- });
+ m_scheduler.schedule(m_confParam.getFaceDatasetFetchInterval(), [this] {
+ initializeFaces(
+ [this] (const auto& faces) { processFaceDataset(faces); },
+ [this] (uint32_t code, const std::string& msg) { onFaceDatasetFetchTimeout(code, msg, 0); });
});
}