chunks+ping: follow ndn::Scheduler API changes
Refs: #4883
Change-Id: I8aa48fe4f0613f529763f2efaf799c5db48a0b2c
diff --git a/tools/chunks/catchunks/data-fetcher.cpp b/tools/chunks/catchunks/data-fetcher.cpp
index 7600016..43d5076 100644
--- a/tools/chunks/catchunks/data-fetcher.cpp
+++ b/tools/chunks/catchunks/data-fetcher.cpp
@@ -126,13 +126,13 @@
}
case lp::NackReason::CONGESTION: {
time::milliseconds backoffTime(static_cast<uint64_t>(std::pow(2, m_nCongestionRetries)));
- if (backoffTime > MAX_CONGESTION_BACKOFF_TIME)
+ if (backoffTime > MAX_CONGESTION_BACKOFF_TIME) {
backoffTime = MAX_CONGESTION_BACKOFF_TIME;
- else
+ }
+ else {
m_nCongestionRetries++;
-
- m_scheduler.scheduleEvent(backoffTime, bind(&DataFetcher::expressInterest, this,
- newInterest, self));
+ }
+ m_scheduler.schedule(backoffTime, [=] { expressInterest(newInterest, self); });
break;
}
default: {
diff --git a/tools/chunks/catchunks/pipeline-interests-adaptive.cpp b/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
index 7e394ef..4ce277d 100644
--- a/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
@@ -82,7 +82,7 @@
}
// schedule the event to check retransmission timer
- m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
+ m_checkRtoEvent = m_scheduler.schedule(m_options.rtoCheckInterval, [this] { checkRto(); });
schedulePackets();
}
@@ -120,7 +120,7 @@
}
// schedule the next check after predefined interval
- m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
+ m_checkRtoEvent = m_scheduler.schedule(m_options.rtoCheckInterval, [this] { checkRto(); });
}
void
diff --git a/tools/ping/client/ping.cpp b/tools/ping/client/ping.cpp
index b83c160..e3cb20f 100644
--- a/tools/ping/client/ping.cpp
+++ b/tools/ping/client/ping.cpp
@@ -58,25 +58,23 @@
{
BOOST_ASSERT((m_options.nPings < 0) || (m_nSent < m_options.nPings));
- Name pingPacketName = makePingName(m_nextSeq);
-
- Interest interest(pingPacketName);
+ Interest interest(makePingName(m_nextSeq));
interest.setCanBePrefix(false);
interest.setMustBeFresh(!m_options.shouldAllowStaleData);
interest.setInterestLifetime(m_options.timeout);
auto now = time::steady_clock::now();
m_face.expressInterest(interest,
- bind(&Ping::onData, this, _1, _2, m_nextSeq, now),
- bind(&Ping::onNack, this, _1, _2, m_nextSeq, now),
- bind(&Ping::onTimeout, this, _1, m_nextSeq));
+ bind(&Ping::onData, this, m_nextSeq, now),
+ bind(&Ping::onNack, this, _2, m_nextSeq, now),
+ bind(&Ping::onTimeout, this, m_nextSeq));
++m_nSent;
++m_nextSeq;
++m_nOutstanding;
if ((m_options.nPings < 0) || (m_nSent < m_options.nPings)) {
- m_nextPingEvent = m_scheduler.scheduleEvent(m_options.interval, bind(&Ping::performPing, this));
+ m_nextPingEvent = m_scheduler.schedule(m_options.interval, [this] { performPing(); });
}
else {
finish();
@@ -84,36 +82,25 @@
}
void
-Ping::onData(const Interest& interest,
- const Data& data,
- uint64_t seq,
- const time::steady_clock::TimePoint& sendTime)
+Ping::onData(uint64_t seq, const time::steady_clock::TimePoint& sendTime)
{
time::nanoseconds rtt = time::steady_clock::now() - sendTime;
-
afterData(seq, rtt);
-
finish();
}
void
-Ping::onNack(const Interest& interest,
- const lp::Nack& nack,
- uint64_t seq,
- const time::steady_clock::TimePoint& sendTime)
+Ping::onNack(const lp::Nack& nack, uint64_t seq, const time::steady_clock::TimePoint& sendTime)
{
time::nanoseconds rtt = time::steady_clock::now() - sendTime;
-
afterNack(seq, rtt, nack.getHeader());
-
finish();
}
void
-Ping::onTimeout(const Interest& interest, uint64_t seq)
+Ping::onTimeout(uint64_t seq)
{
afterTimeout(seq);
-
finish();
}
@@ -123,7 +110,6 @@
if (--m_nOutstanding >= 0) {
return;
}
-
afterFinish();
}
@@ -135,8 +121,7 @@
if (!m_options.clientIdentifier.empty()) {
name.append(m_options.clientIdentifier);
}
- name.append(std::to_string(seq));
-
+ name.append(to_string(seq));
return name;
}
diff --git a/tools/ping/client/ping.hpp b/tools/ping/client/ping.hpp
index f2a78d9..aeab96f 100644
--- a/tools/ping/client/ping.hpp
+++ b/tools/ping/client/ping.hpp
@@ -121,16 +121,11 @@
/**
* @brief Called when a Data packet is received in response to a ping
*
- * @param interest NDN interest
- * @param data returned data
* @param seq ping sequence number
* @param sendTime time ping sent
*/
void
- onData(const Interest& interest,
- const Data& data,
- uint64_t seq,
- const time::steady_clock::TimePoint& sendTime);
+ onData(uint64_t seq, const time::steady_clock::TimePoint& sendTime);
/**
* @brief Called when a Nack is received in response to a ping
@@ -141,9 +136,7 @@
* @param sendTime time ping sent
*/
void
- onNack(const Interest& interest,
- const lp::Nack& nack,
- uint64_t seq,
+ onNack(const lp::Nack& nack, uint64_t seq,
const time::steady_clock::TimePoint& sendTime);
/**
@@ -153,7 +146,7 @@
* @param seq ping sequence number
*/
void
- onTimeout(const Interest& interest, uint64_t seq);
+ onTimeout(uint64_t seq);
/**
* @brief Called after ping received or timed out