Task #4848
closedPendingEntryInfoFull::expirationEvent is unused
0%
Description
This is a low-priority observation. In the PendingEntryInfoFull struct, the expirationEvent member is assigned but never used.
https://github.com/named-data/PSync/blob/e5fdcc3744d3787949aec0ef23ba9fc8a7db4572/PSync/full-producer.hpp#L44
struct PendingEntryInfoFull
{
IBLT iblt;
ndn::util::scheduler::ScopedEventId expirationEvent;
};
Here is where expirationEvent is assigned but never used:
https://github.com/named-data/PSync/blob/e5fdcc3744d3787949aec0ef23ba9fc8a7db4572/PSync/full-producer.cpp#L210
entry.expirationEvent = m_scheduler.scheduleEvent(interest.getInterestLifetime(),
[this, interest] {
NDN_LOG_TRACE("Erase Pending Interest " << interest.getNonce());
m_pendingEntries.erase(interest.getName());
});
Therefore, expirationEvent can be removed. Now, PendingEntryInfoFull only has one member, iblt. So, PendingEntryInfoFull can also be removed, since it is only used by the m_pendingEntries map.
https://github.com/named-data/PSync/blob/e5fdcc3744d3787949aec0ef23ba9fc8a7db4572/PSync/full-producer.hpp#L187
std::map<ndn::Name, PendingEntryInfoFull> m_pendingEntries;
This can be changed to:
std::map<ndn::Name, IBLT> m_pendingEntries;
(It looks like the same argument applies to PendingEntryInfo::expirationEvent .)
https://github.com/named-data/PSync/blob/e5fdcc3744d3787949aec0ef23ba9fc8a7db4572/PSync/partial-producer.hpp#L40
Updated by Ashlesh Gawande about 5 years ago
I think it is used cancel the last expiration event (https://github.com/named-data/ndn-cxx/blob/923ba4415f83eeef2f1021da3bf945a0ab2d7c56/ndn-cxx/util/scheduler.hpp#L119) because it is ScopedEventId.
Updated by Anonymous about 5 years ago
OK, so it is used. A question: The m_pendingEntries map can internally make copies of the PendingEntryInfoFull. You're sure that the ScopedEventId destructor is never called unexpectedly as map does its thing?
Updated by Ashlesh Gawande about 5 years ago
Huh, not sure about that - need to read more about map and test.
Updated by Davide Pesavento over 2 years ago
- Status changed from New to Rejected
- Start date deleted (
02/15/2019)
Jeff Thompson wrote in #note-2:
The m_pendingEntries map can internally make copies of the PendingEntryInfoFull.
No, it cannot. std::map
does not require a copyable mapped type (in C++11 and later).
You're sure that the ScopedEventId destructor is never called unexpectedly as map does its thing?
Yes. ScopedEventId
is non-copyable by design to avoid this problem.