chunks: don't blindly call Scheduler::cancellAllEvents()
Instead, keep track of the event we schedule and cancel only that one.
Change-Id: I9a2ae73073537bb1b67bceef85670add741cd542
diff --git a/tools/chunks/catchunks/pipeline-interests-aimd.cpp b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
index cbff235..2b7af06 100644
--- a/tools/chunks/catchunks/pipeline-interests-aimd.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
@@ -1,7 +1,7 @@
/**
- * Copyright (c) 2016, Regents of the University of California,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University.
+ * Copyright (c) 2016-2017, Regents of the University of California,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -37,6 +37,7 @@
, m_options(options)
, m_rttEstimator(rttEstimator)
, m_scheduler(m_face.getIoService())
+ , m_checkRtoEvent(m_scheduler)
, m_nextSegmentNo(0)
, m_receivedSize(0)
, m_highData(0)
@@ -71,7 +72,7 @@
m_nReceived++;
// schedule the event to check retransmission timer
- m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
+ m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
sendInterest(getNextSegmentNo(), false);
}
@@ -80,11 +81,10 @@
PipelineInterestsAimd::doCancel()
{
for (const auto& entry : m_segmentInfo) {
- const SegmentInfo& segInfo = entry.second;
- m_face.removePendingInterest(segInfo.interestId);
+ m_face.removePendingInterest(entry.second.interestId);
}
+ m_checkRtoEvent.cancel();
m_segmentInfo.clear();
- m_scheduler.cancelAllEvents();
}
void
@@ -114,7 +114,7 @@
}
// schedule the next check after predefined interval
- m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
+ m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
}
void
diff --git a/tools/chunks/catchunks/pipeline-interests-aimd.hpp b/tools/chunks/catchunks/pipeline-interests-aimd.hpp
index 3d8e337..c67d5bc 100644
--- a/tools/chunks/catchunks/pipeline-interests-aimd.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-aimd.hpp
@@ -1,7 +1,7 @@
/**
- * Copyright (c) 2016, Regents of the University of California,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University.
+ * Copyright (c) 2016-2017, Regents of the University of California,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -118,13 +118,13 @@
* every segment until the last segment is successfully received or an error occurs.
* The segment with segment number equal to m_excludedSegmentNo will not be fetched.
*/
- virtual void
+ void
doRun() final;
/**
* @brief stop all fetch operations
*/
- virtual void
+ void
doCancel() final;
/**
@@ -186,20 +186,22 @@
const Options m_options;
RttEstimator& m_rttEstimator;
Scheduler m_scheduler;
+ scheduler::ScopedEventId m_checkRtoEvent;
+
uint64_t m_nextSegmentNo;
size_t m_receivedSize;
uint64_t m_highData; ///< the highest segment number of the Data packet the consumer has received so far
uint64_t m_highInterest; ///< the highest segment number of the Interests the consumer has sent so far
- uint64_t m_recPoint; ///< the value of m_highInterest when a packet loss event occurred
- ///< It remains fixed until the next packet loss event happens
+ uint64_t m_recPoint; ///< the value of m_highInterest when a packet loss event occurred,
+ ///< it remains fixed until the next packet loss event happens
uint64_t m_nInFlight; ///< # of segments in flight
uint64_t m_nReceived; ///< # of segments received
uint64_t m_nLossEvents; ///< # of loss events occurred
uint64_t m_nRetransmitted; ///< # of segments retransmitted
- time::steady_clock::TimePoint m_startTime; ///< start time of pipelining
+ time::steady_clock::TimePoint m_startTime; ///< start time of pipelining
double m_cwnd; ///< current congestion window size (in segments)
double m_ssthresh; ///< current slow start threshold