fw: pass const shared_ptr<pit::Entry>& to Strategy triggers
refs #3205
Change-Id: I8f227c57ee6733526f0569de81f20677210cafa4
diff --git a/daemon/fw/access-strategy.cpp b/daemon/fw/access-strategy.cpp
index bb41fba..9d4df0c 100644
--- a/daemon/fw/access-strategy.cpp
+++ b/daemon/fw/access-strategy.cpp
@@ -42,14 +42,9 @@
{
}
-AccessStrategy::~AccessStrategy()
-{
-}
-
void
-AccessStrategy::afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+AccessStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
RetxSuppression::Result suppressResult = m_retxSuppression.decide(inFace, interest, *pitEntry);
switch (suppressResult) {
@@ -69,9 +64,8 @@
}
void
-AccessStrategy::afterReceiveNewInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+AccessStrategy::afterReceiveNewInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
Name miName;
@@ -102,9 +96,8 @@
}
void
-AccessStrategy::afterReceiveRetxInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+AccessStrategy::afterReceiveRetxInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
NFD_LOG_DEBUG(interest << " interestFrom " << inFace.getId() << " retx-forward");
@@ -112,8 +105,8 @@
}
bool
-AccessStrategy::sendToLastNexthop(const Face& inFace, shared_ptr<pit::Entry> pitEntry, MtInfo& mi,
- const fib::Entry& fibEntry)
+AccessStrategy::sendToLastNexthop(const Face& inFace, const shared_ptr<pit::Entry>& pitEntry,
+ MtInfo& mi, const fib::Entry& fibEntry)
{
if (mi.lastNexthop == face::INVALID_FACEID) {
NFD_LOG_DEBUG(pitEntry->getInterest() << " no-last-nexthop");
@@ -152,8 +145,7 @@
}
void
-AccessStrategy::afterRtoTimeout(weak_ptr<pit::Entry> pitWeak,
- FaceId inFace, FaceId firstOutFace)
+AccessStrategy::afterRtoTimeout(weak_ptr<pit::Entry> pitWeak, FaceId inFace, FaceId firstOutFace)
{
shared_ptr<pit::Entry> pitEntry = pitWeak.lock();
BOOST_ASSERT(pitEntry != nullptr);
@@ -167,7 +159,7 @@
}
void
-AccessStrategy::multicast(shared_ptr<pit::Entry> pitEntry, const fib::Entry& fibEntry,
+AccessStrategy::multicast(const shared_ptr<pit::Entry>& pitEntry, const fib::Entry& fibEntry,
std::unordered_set<FaceId> exceptFaces)
{
for (const fib::NextHop& nexthop : fibEntry.getNextHops()) {
@@ -182,7 +174,7 @@
}
void
-AccessStrategy::beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
+AccessStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
const Face& inFace, const Data& data)
{
shared_ptr<PitInfo> pi = pitEntry->getStrategyInfo<PitInfo>();
diff --git a/daemon/fw/access-strategy.hpp b/daemon/fw/access-strategy.hpp
index 02a7965..b71f2c6 100644
--- a/daemon/fw/access-strategy.hpp
+++ b/daemon/fw/access-strategy.hpp
@@ -49,19 +49,16 @@
class AccessStrategy : public Strategy
{
public:
+ explicit
AccessStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
- virtual
- ~AccessStrategy();
-
public: // triggers
virtual void
- afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry) override;
+ afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry) override;
virtual void
- beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
+ beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
const Face& inFace, const Data& data) override;
private: // StrategyInfo
@@ -127,20 +124,18 @@
private: // forwarding procedures
void
- afterReceiveNewInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry);
+ afterReceiveNewInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry);
void
- afterReceiveRetxInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry);
+ afterReceiveRetxInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry);
/** \brief send to last working nexthop
* \return whether an Interest is sent
*/
bool
- sendToLastNexthop(const Face& inFace, shared_ptr<pit::Entry> pitEntry, MtInfo& mi,
+ sendToLastNexthop(const Face& inFace, const shared_ptr<pit::Entry>& pitEntry, MtInfo& mi,
const fib::Entry& fibEntry);
void
@@ -150,8 +145,7 @@
* \param exceptFaces don't forward to those faces
*/
void
- multicast(shared_ptr<pit::Entry> pitEntry,
- const fib::Entry& fibEntry,
+ multicast(const shared_ptr<pit::Entry>& pitEntry, const fib::Entry& fibEntry,
std::unordered_set<FaceId> exceptFaces = std::unordered_set<FaceId>());
void
diff --git a/daemon/fw/asf-measurements.cpp b/daemon/fw/asf-measurements.cpp
index 11249f8..c15aca0 100644
--- a/daemon/fw/asf-measurements.cpp
+++ b/daemon/fw/asf-measurements.cpp
@@ -110,7 +110,7 @@
}
void
-FaceInfo::recordRtt(const shared_ptr<pit::Entry> pitEntry, const Face& inFace)
+FaceInfo::recordRtt(const shared_ptr<pit::Entry>& pitEntry, const Face& inFace)
{
// Calculate RTT
pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(inFace);
diff --git a/daemon/fw/asf-measurements.hpp b/daemon/fw/asf-measurements.hpp
index 64f88c2..205219d 100644
--- a/daemon/fw/asf-measurements.hpp
+++ b/daemon/fw/asf-measurements.hpp
@@ -131,7 +131,7 @@
}
void
- recordRtt(const shared_ptr<pit::Entry> pitEntry, const Face& inFace);
+ recordRtt(const shared_ptr<pit::Entry>& pitEntry, const Face& inFace);
void
recordTimeout(const ndn::Name& interestName);
diff --git a/daemon/fw/asf-strategy.cpp b/daemon/fw/asf-strategy.cpp
index 3f8abf7..9ed2c77 100644
--- a/daemon/fw/asf-strategy.cpp
+++ b/daemon/fw/asf-strategy.cpp
@@ -49,14 +49,9 @@
{
}
-AsfStrategy::~AsfStrategy()
-{
-}
-
void
-AsfStrategy::afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+AsfStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
// Should the Interest be suppressed?
RetxSuppression::Result suppressResult = m_retxSuppression.decide(inFace, interest, *pitEntry);
@@ -105,9 +100,8 @@
}
void
-AsfStrategy::beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
- const Face& inFace,
- const Data& data)
+AsfStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
+ const Face& inFace, const Data& data)
{
shared_ptr<NamespaceInfo> namespaceInfo = m_measurements.getNamespaceInfo(pitEntry->getName());
@@ -130,7 +124,7 @@
void
AsfStrategy::afterReceiveNack(const Face& inFace, const lp::Nack& nack,
- shared_ptr<pit::Entry> pitEntry)
+ const shared_ptr<pit::Entry>& pitEntry)
{
NFD_LOG_DEBUG("Nack for " << nack.getInterest() << " from=" << inFace.getId() << ": " << nack.getReason());
onTimeout(pitEntry->getName(), inFace.getId());
@@ -142,7 +136,7 @@
void
AsfStrategy::forwardInterest(const Interest& interest,
const fib::Entry& fibEntry,
- shared_ptr<pit::Entry> pitEntry,
+ const shared_ptr<pit::Entry>& pitEntry,
Face& outFace,
bool wantNewNonce)
{
@@ -197,7 +191,8 @@
}
Face*
-AsfStrategy::getBestFaceForForwarding(const fib::Entry& fibEntry, const ndn::Interest& interest, const Face& inFace)
+AsfStrategy::getBestFaceForForwarding(const fib::Entry& fibEntry, const Interest& interest,
+ const Face& inFace)
{
NFD_LOG_TRACE("Looking for best face for " << fibEntry.getPrefix());
@@ -255,7 +250,7 @@
}
void
-AsfStrategy::onTimeout(const ndn::Name& interestName, nfd::face::FaceId faceId)
+AsfStrategy::onTimeout(const Name& interestName, face::FaceId faceId)
{
NFD_LOG_TRACE("FaceId: " << faceId << " for " << interestName << " has timed-out");
@@ -277,7 +272,8 @@
}
void
-AsfStrategy::sendNoRouteNack(const Face& inFace, const Interest& interest, shared_ptr<pit::Entry> pitEntry)
+AsfStrategy::sendNoRouteNack(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
NFD_LOG_DEBUG(interest << " from=" << inFace.getId() << " noNextHop");
diff --git a/daemon/fw/asf-strategy.hpp b/daemon/fw/asf-strategy.hpp
index ad00a3d..8975d6b 100644
--- a/daemon/fw/asf-strategy.hpp
+++ b/daemon/fw/asf-strategy.hpp
@@ -47,39 +47,35 @@
explicit
AsfStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
- virtual
- ~AsfStrategy();
-
public: // triggers
virtual void
- afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry) override;
+ afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry) override;
virtual void
- beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
+ beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
const Face& inFace, const Data& data) override;
virtual void
afterReceiveNack(const Face& inFace, const lp::Nack& nack,
- shared_ptr<pit::Entry> pitEntry) override;
+ const shared_ptr<pit::Entry>& pitEntry) override;
private:
void
forwardInterest(const Interest& interest,
const fib::Entry& fibEntry,
- shared_ptr<pit::Entry> pitEntry,
+ const shared_ptr<pit::Entry>& pitEntry,
Face& outFace,
bool wantNewNonce = false);
Face*
- getBestFaceForForwarding(const fib::Entry& fibEntry, const ndn::Interest& interest, const Face& inFace);
+ getBestFaceForForwarding(const fib::Entry& fibEntry, const Interest& interest, const Face& inFace);
void
- onTimeout(const ndn::Name& interestName, nfd::face::FaceId faceId);
+ onTimeout(const Name& interestName, face::FaceId faceId);
void
- sendNoRouteNack(const Face& inFace, const Interest& interest, shared_ptr<pit::Entry> pitEntry);
+ sendNoRouteNack(const Face& inFace, const Interest& interest, const shared_ptr<pit::Entry>& pitEntry);
public:
static const Name STRATEGY_NAME;
diff --git a/daemon/fw/best-route-strategy.cpp b/daemon/fw/best-route-strategy.cpp
index b97afca..ac166f4 100644
--- a/daemon/fw/best-route-strategy.cpp
+++ b/daemon/fw/best-route-strategy.cpp
@@ -37,14 +37,9 @@
{
}
-BestRouteStrategy::~BestRouteStrategy()
-{
-}
-
void
-BestRouteStrategy::afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+BestRouteStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
if (hasPendingOutRecords(*pitEntry)) {
// not a new Interest, don't forward
diff --git a/daemon/fw/best-route-strategy.hpp b/daemon/fw/best-route-strategy.hpp
index 9480b96..b24f62e 100644
--- a/daemon/fw/best-route-strategy.hpp
+++ b/daemon/fw/best-route-strategy.hpp
@@ -45,15 +45,12 @@
class BestRouteStrategy : public Strategy
{
public:
+ explicit
BestRouteStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
- virtual
- ~BestRouteStrategy();
-
virtual void
- afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry) override;
+ afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry) override;
public:
static const Name STRATEGY_NAME;
diff --git a/daemon/fw/best-route-strategy2.cpp b/daemon/fw/best-route-strategy2.cpp
index 5080d9c..e897b49 100644
--- a/daemon/fw/best-route-strategy2.cpp
+++ b/daemon/fw/best-route-strategy2.cpp
@@ -104,9 +104,8 @@
}
void
-BestRouteStrategy2::afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+BestRouteStrategy2::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
RetxSuppression::Result suppression = m_retxSuppression.decide(inFace, interest, *pitEntry);
if (suppression == RetxSuppression::SUPPRESS) {
@@ -186,7 +185,7 @@
void
BestRouteStrategy2::afterReceiveNack(const Face& inFace, const lp::Nack& nack,
- shared_ptr<pit::Entry> pitEntry)
+ const shared_ptr<pit::Entry>& pitEntry)
{
int nOutRecordsNotNacked = 0;
Face* lastFaceNotNacked = nullptr;
diff --git a/daemon/fw/best-route-strategy2.hpp b/daemon/fw/best-route-strategy2.hpp
index d78baf6..a27664f 100644
--- a/daemon/fw/best-route-strategy2.hpp
+++ b/daemon/fw/best-route-strategy2.hpp
@@ -52,17 +52,16 @@
class BestRouteStrategy2 : public Strategy
{
public:
+ explicit
BestRouteStrategy2(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
virtual void
afterReceiveInterest(const Face& inFace, const Interest& interest,
-
- shared_ptr<pit::Entry> pitEntry) override;
+ const shared_ptr<pit::Entry>& pitEntry) override;
virtual void
afterReceiveNack(const Face& inFace, const lp::Nack& nack,
-
- shared_ptr<pit::Entry> pitEntry) override;
+ const shared_ptr<pit::Entry>& pitEntry) override;
public:
static const Name STRATEGY_NAME;
diff --git a/daemon/fw/broadcast-strategy.cpp b/daemon/fw/broadcast-strategy.cpp
index 3a3249c..253efc8 100644
--- a/daemon/fw/broadcast-strategy.cpp
+++ b/daemon/fw/broadcast-strategy.cpp
@@ -40,9 +40,8 @@
}
void
-BroadcastStrategy::afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+BroadcastStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
if (m_isFirstUse) {
NFD_LOG_WARN("The broadcast strategy has been renamed as multicast strategy. "
diff --git a/daemon/fw/broadcast-strategy.hpp b/daemon/fw/broadcast-strategy.hpp
index 1f868b5..1ef781c 100644
--- a/daemon/fw/broadcast-strategy.hpp
+++ b/daemon/fw/broadcast-strategy.hpp
@@ -37,12 +37,12 @@
class BroadcastStrategy : public MulticastStrategy
{
public:
+ explicit
BroadcastStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
virtual void
- afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry) override;
+ afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry) override;
public:
static const Name STRATEGY_NAME;
diff --git a/daemon/fw/client-control-strategy.cpp b/daemon/fw/client-control-strategy.cpp
index 0779cc1..147b936 100644
--- a/daemon/fw/client-control-strategy.cpp
+++ b/daemon/fw/client-control-strategy.cpp
@@ -40,14 +40,9 @@
{
}
-ClientControlStrategy::~ClientControlStrategy()
-{
-}
-
void
-ClientControlStrategy::afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+ClientControlStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
shared_ptr<lp::NextHopFaceIdTag> tag = interest.getTag<lp::NextHopFaceIdTag>();
if (tag == nullptr) {
diff --git a/daemon/fw/client-control-strategy.hpp b/daemon/fw/client-control-strategy.hpp
index 2a3bbb2..68b4441 100644
--- a/daemon/fw/client-control-strategy.hpp
+++ b/daemon/fw/client-control-strategy.hpp
@@ -40,15 +40,12 @@
class ClientControlStrategy : public BestRouteStrategy
{
public:
+ explicit
ClientControlStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
- virtual
- ~ClientControlStrategy();
-
virtual void
- afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry) override;
+ afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry) override;
public:
static const Name STRATEGY_NAME;
diff --git a/daemon/fw/multicast-strategy.cpp b/daemon/fw/multicast-strategy.cpp
index 5373d03..44c8c52 100644
--- a/daemon/fw/multicast-strategy.cpp
+++ b/daemon/fw/multicast-strategy.cpp
@@ -38,9 +38,8 @@
}
void
-MulticastStrategy::afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+MulticastStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
const fib::NextHopList& nexthops = fibEntry.getNextHops();
diff --git a/daemon/fw/multicast-strategy.hpp b/daemon/fw/multicast-strategy.hpp
index 1330186..2ab3f8d 100644
--- a/daemon/fw/multicast-strategy.hpp
+++ b/daemon/fw/multicast-strategy.hpp
@@ -39,9 +39,8 @@
MulticastStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
virtual void
- afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry) override;
+ afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry) override;
public:
static const Name STRATEGY_NAME;
diff --git a/daemon/fw/ncc-strategy.cpp b/daemon/fw/ncc-strategy.cpp
index 213ce59..b127fea 100644
--- a/daemon/fw/ncc-strategy.cpp
+++ b/daemon/fw/ncc-strategy.cpp
@@ -39,18 +39,13 @@
{
}
-NccStrategy::~NccStrategy()
-{
-}
-
const time::microseconds NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE = time::microseconds(4000);
const time::microseconds NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE = time::microseconds(75000);
const time::nanoseconds NccStrategy::MEASUREMENTS_LIFETIME = time::seconds(16);
void
-NccStrategy::afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry)
+NccStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
const fib::NextHopList& nexthops = fibEntry.getNextHops();
@@ -59,8 +54,7 @@
return;
}
- shared_ptr<PitEntryInfo> pitEntryInfo =
- pitEntry->getOrCreateStrategyInfo<PitEntryInfo>();
+ shared_ptr<PitEntryInfo> pitEntryInfo = pitEntry->getOrCreateStrategyInfo<PitEntryInfo>();
bool isNewPitEntry = !hasPendingOutRecords(*pitEntry);
if (!isNewPitEntry) {
return;
@@ -112,8 +106,7 @@
pitEntryInfo->maxInterval = deferFirst;
}
pitEntryInfo->propagateTimer = scheduler::schedule(deferFirst,
- bind(&NccStrategy::doPropagate, this,
- weak_ptr<pit::Entry>(pitEntry)));
+ bind(&NccStrategy::doPropagate, this, weak_ptr<pit::Entry>(pitEntry)));
}
void
@@ -182,7 +175,7 @@
}
void
-NccStrategy::beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
+NccStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
const Face& inFace, const Data& data)
{
if (!pitEntry->hasInRecords()) {
@@ -220,7 +213,7 @@
}
NccStrategy::MeasurementsEntryInfo&
-NccStrategy::getMeasurementsEntryInfo(shared_ptr<pit::Entry> entry)
+NccStrategy::getMeasurementsEntryInfo(const shared_ptr<pit::Entry>& entry)
{
measurements::Entry* measurementsEntry = this->getMeasurements().get(*entry);
return this->getMeasurementsEntryInfo(measurementsEntry);
diff --git a/daemon/fw/ncc-strategy.hpp b/daemon/fw/ncc-strategy.hpp
index 80e2918..5043ee3 100644
--- a/daemon/fw/ncc-strategy.hpp
+++ b/daemon/fw/ncc-strategy.hpp
@@ -36,18 +36,15 @@
class NccStrategy : public Strategy
{
public:
+ explicit
NccStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
- virtual
- ~NccStrategy();
+ virtual void
+ afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry) override;
virtual void
- afterReceiveInterest(const Face& inFace,
- const Interest& interest,
- shared_ptr<pit::Entry> pitEntry) override;
-
- virtual void
- beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
+ beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
const Face& inFace, const Data& data) override;
PUBLIC_WITH_TESTS_ELSE_PROTECTED:
@@ -105,7 +102,7 @@
}
virtual
- ~PitEntryInfo();
+ ~PitEntryInfo() override;
public:
/// timer that expires when best face does not respond within predicted time
@@ -121,7 +118,7 @@
getMeasurementsEntryInfo(measurements::Entry* entry);
MeasurementsEntryInfo&
- getMeasurementsEntryInfo(shared_ptr<pit::Entry> entry);
+ getMeasurementsEntryInfo(const shared_ptr<pit::Entry>& entry);
/// propagate to another upstream
void
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index f645369..53b8935 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -37,32 +37,29 @@
, beforeRemoveFace(forwarder.getFaceTable().beforeRemove)
, m_name(name)
, m_forwarder(forwarder)
- , m_measurements(m_forwarder.getMeasurements(),
- m_forwarder.getStrategyChoice(), *this)
+ , m_measurements(m_forwarder.getMeasurements(), m_forwarder.getStrategyChoice(), *this)
{
}
-Strategy::~Strategy()
-{
-}
+Strategy::~Strategy() = default;
void
-Strategy::beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
+Strategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
const Face& inFace, const Data& data)
{
NFD_LOG_DEBUG("beforeSatisfyInterest pitEntry=" << pitEntry->getName() <<
- " inFace=" << inFace.getId() << " data=" << data.getName());
+ " inFace=" << inFace.getId() << " data=" << data.getName());
}
void
-Strategy::beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry)
+Strategy::beforeExpirePendingInterest(const shared_ptr<pit::Entry>& pitEntry)
{
NFD_LOG_DEBUG("beforeExpirePendingInterest pitEntry=" << pitEntry->getName());
}
void
Strategy::afterReceiveNack(const Face& inFace, const lp::Nack& nack,
- shared_ptr<pit::Entry> pitEntry)
+ const shared_ptr<pit::Entry>& pitEntry)
{
NFD_LOG_DEBUG("afterReceiveNack inFace=" << inFace.getId() <<
" pitEntry=" << pitEntry->getName());
diff --git a/daemon/fw/strategy.hpp b/daemon/fw/strategy.hpp
index 4f51f3b..4f3da2c 100644
--- a/daemon/fw/strategy.hpp
+++ b/daemon/fw/strategy.hpp
@@ -69,12 +69,12 @@
* - If strategy concludes that this Interest cannot be forwarded,
* invoke this->rejectPendingInterest so that PIT entry will be deleted shortly
*
- * \note The strategy is permitted to store a shared reference to pitEntry.
- * pitEntry is passed by value to reflect this fact.
+ * \warning The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior
+ * may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>.
*/
virtual void
afterReceiveInterest(const Face& inFace, const Interest& interest,
- shared_ptr<pit::Entry> pitEntry) = 0;
+ const shared_ptr<pit::Entry>& pitEntry) = 0;
/** \brief trigger before PIT entry is satisfied
*
@@ -83,11 +83,11 @@
*
* In this base class this method does nothing.
*
- * \note The strategy is permitted to store a shared reference to pitEntry.
- * pitEntry is passed by value to reflect this fact.
+ * \warning The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior
+ * may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>.
*/
virtual void
- beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
+ beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
const Face& inFace, const Data& data);
/** \brief trigger before PIT entry expires
@@ -99,11 +99,12 @@
*
* In this base class this method does nothing.
*
- * \note The strategy is permitted to store a shared reference to pitEntry.
- * pitEntry is passed by value to reflect this fact.
+ * \warning The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior
+ * may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>,
+ * although this isn't useful here because PIT entry would be deleted shortly after.
*/
virtual void
- beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry);
+ beforeExpirePendingInterest(const shared_ptr<pit::Entry>& pitEntry);
/** \brief trigger after Nack is received
*
@@ -115,12 +116,12 @@
*
* In this base class this method does nothing.
*
- * \note The strategy is permitted to store a shared reference to pitEntry.
- * pitEntry is passed by value to reflect this fact.
+ * \warning The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior
+ * may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>.
*/
virtual void
afterReceiveNack(const Face& inFace, const lp::Nack& nack,
- shared_ptr<pit::Entry> pitEntry);
+ const shared_ptr<pit::Entry>& pitEntry);
protected: // actions
/** \brief send Interest to outFace