Follow ndn::Scheduler API changes
Refs: #4883
Change-Id: I71e39f13f62302248d13825481d06d10f694cd94
diff --git a/src/interest-table.cpp b/src/interest-table.cpp
index 2b3c9d6..8b98316 100644
--- a/src/interest-table.cpp
+++ b/src/interest-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2017 University of California, Los Angeles
+ * Copyright (c) 2012-2019 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -47,7 +47,7 @@
if (entryLifetime < time::milliseconds::zero())
entryLifetime = ndn::DEFAULT_INTEREST_LIFETIME;
- request->expirationEvent = m_scheduler.scheduleEvent(entryLifetime, [=] { erase(digest); });
+ request->expirationEvent = m_scheduler.schedule(entryLifetime, [=] { erase(digest); });
m_table.insert(request);
}
@@ -57,7 +57,7 @@
{
auto it = m_table.get<hashed>().find(digest);
while (it != m_table.get<hashed>().end()) {
- m_scheduler.cancelEvent((*it)->expirationEvent);
+ (*it)->expirationEvent.cancel();
m_table.erase(it);
it = m_table.get<hashed>().find(digest);
@@ -83,9 +83,8 @@
InterestTable::clear()
{
for (const auto& item : m_table) {
- m_scheduler.cancelEvent(item->expirationEvent);
+ item->expirationEvent.cancel();
}
-
m_table.clear();
}
diff --git a/src/logic.cpp b/src/logic.cpp
index ead98ae..fa6680d 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -168,8 +168,7 @@
sendSyncInterest();
- m_delayedInterestProcessingId = m_scheduler.scheduleEvent(m_cancelResetTimer,
- bind(&Logic::cancelReset, this));
+ m_delayedInterestProcessingId = m_scheduler.schedule(m_cancelResetTimer, [this] { cancelReset(); });
}
void
@@ -428,8 +427,8 @@
// Do not hurry, some others may be also resetting and may send their reply
time::milliseconds after(m_rangeUniformRandom(m_rng));
_LOG_DEBUG_ID("After: " << after);
- m_delayedInterestProcessingId = m_scheduler.scheduleEvent(after,
- bind(&Logic::processSyncInterest, this, interest, true));
+ m_delayedInterestProcessingId = m_scheduler.schedule(after,
+ [=] { processSyncInterest(interest, true); });
}
else {
_LOG_DEBUG_ID("Timed processing in reset");
@@ -461,8 +460,8 @@
m_interestTable.insert(interest, digest, true);
m_delayedInterestProcessingId =
- m_scheduler.scheduleEvent(time::milliseconds(m_rangeUniformRandom(m_rng)),
- bind(&Logic::processSyncInterest, this, interest, true));
+ m_scheduler.schedule(time::milliseconds(m_rangeUniformRandom(m_rng)),
+ [=] { processSyncInterest(interest, true); });
}
else {
// OK, nobody is helping us, just tell the truth.
@@ -497,25 +496,24 @@
reply.wireDecode(syncReplyBlock);
std::vector<MissingDataInfo> v;
- BOOST_FOREACH(ConstLeafPtr leaf, reply.getLeaves().get<ordered>())
- {
- BOOST_ASSERT(leaf != 0);
+ BOOST_FOREACH(ConstLeafPtr leaf, reply.getLeaves().get<ordered>()) {
+ BOOST_ASSERT(leaf != nullptr);
- const Name& info = leaf->getSessionName();
- SeqNo seq = leaf->getSeq();
+ const Name& info = leaf->getSessionName();
+ SeqNo seq = leaf->getSeq();
- bool isInserted = false;
- bool isUpdated = false;
- SeqNo oldSeq;
- std::tie(isInserted, isUpdated, oldSeq) = m_state.update(info, seq);
- if (isInserted || isUpdated) {
- commit->update(info, seq);
+ bool isInserted = false;
+ bool isUpdated = false;
+ SeqNo oldSeq;
+ std::tie(isInserted, isUpdated, oldSeq) = m_state.update(info, seq);
+ if (isInserted || isUpdated) {
+ commit->update(info, seq);
- oldSeq++;
- MissingDataInfo mdi = {info, oldSeq, seq};
- v.push_back(mdi);
- }
+ oldSeq++;
+ MissingDataInfo mdi = {info, oldSeq, seq};
+ v.push_back(mdi);
}
+ }
if (!v.empty()) {
m_onUpdate(v);
@@ -538,8 +536,7 @@
// state changed and it is safe to express a new interest
auto after = time::milliseconds(m_reexpressionJitter(m_rng));
_LOG_DEBUG_ID("Reschedule sync interest after: " << after);
- m_reexpressingInterestId = m_scheduler.scheduleEvent(after,
- bind(&Logic::sendSyncInterest, this));
+ m_reexpressingInterestId = m_scheduler.schedule(after, [this] { sendSyncInterest(); });
}
}
@@ -589,9 +586,8 @@
_LOG_DEBUG_ID("Need Period Reset");
_LOG_DEBUG_ID("ResetTimer: " << m_resetTimer);
- m_resetInterestId = m_scheduler.scheduleEvent(
- m_resetTimer + ndn::time::milliseconds(m_reexpressionJitter(m_rng)),
- bind(&Logic::sendResetInterest, this));
+ m_resetInterestId = m_scheduler.schedule(m_resetTimer + ndn::time::milliseconds(m_reexpressionJitter(m_rng)),
+ [this] { sendResetInterest(); });
}
Interest interest(m_syncReset);
@@ -623,9 +619,9 @@
printDigest(m_state.getRootDigest());
#endif
- m_reexpressingInterestId = m_scheduler.scheduleEvent(m_syncInterestLifetime / 2 +
- ndn::time::milliseconds(m_reexpressionJitter(m_rng)),
- bind(&Logic::sendSyncInterest, this));
+ m_reexpressingInterestId = m_scheduler.schedule(m_syncInterestLifetime / 2 +
+ ndn::time::milliseconds(m_reexpressionJitter(m_rng)),
+ [this] { sendSyncInterest(); });
Interest interest(interestName);
interest.setMustBeFresh(true);
@@ -717,7 +713,7 @@
time::milliseconds after(m_reexpressionJitter(m_rng));
_LOG_DEBUG_ID("Satisfy our own interest");
_LOG_DEBUG_ID("Reschedule sync interest after " << after);
- m_reexpressingInterestId = m_scheduler.scheduleEvent(after, bind(&Logic::sendSyncInterest, this));
+ m_reexpressingInterestId = m_scheduler.schedule(after, [this] { sendSyncInterest(); });
}
_LOG_DEBUG_ID("<< Logic::sendSyncData");
}