41 for (
auto entryInfoMapPair : m_entryInfoMap) {
42 delete entryInfoMapPair.second;
47 PriorityFifoPolicy::doAfterInsert(EntryRef i)
54 PriorityFifoPolicy::doAfterRefresh(EntryRef i)
61 PriorityFifoPolicy::doBeforeErase(EntryRef i)
67 PriorityFifoPolicy::doBeforeUse(EntryRef i)
69 BOOST_ASSERT(m_entryInfoMap.find(i) != m_entryInfoMap.end());
73 PriorityFifoPolicy::evictEntries()
75 BOOST_ASSERT(this->
getCs() !=
nullptr);
83 PriorityFifoPolicy::evictOne()
100 this->detachQueue(i);
105 PriorityFifoPolicy::attachQueue(EntryRef i)
107 BOOST_ASSERT(m_entryInfoMap.find(i) == m_entryInfoMap.end());
109 EntryInfo* entryInfo =
new EntryInfo();
110 if (i->isUnsolicited()) {
113 else if (!i->isFresh()) {
118 entryInfo->moveStaleEventId =
getScheduler().schedule(i->getData().getFreshnessPeriod(),
119 [=] { moveToStaleQueue(i); });
122 Queue& queue = m_queues[entryInfo->queueType];
123 entryInfo->queueIt = queue.insert(queue.end(), i);
124 m_entryInfoMap[i] = entryInfo;
128 PriorityFifoPolicy::detachQueue(EntryRef i)
130 BOOST_ASSERT(m_entryInfoMap.find(i) != m_entryInfoMap.end());
132 EntryInfo* entryInfo = m_entryInfoMap[i];
134 entryInfo->moveStaleEventId.cancel();
137 m_queues[entryInfo->queueType].erase(entryInfo->queueIt);
138 m_entryInfoMap.erase(i);
143 PriorityFifoPolicy::moveToStaleQueue(EntryRef i)
145 BOOST_ASSERT(m_entryInfoMap.find(i) != m_entryInfoMap.end());
147 EntryInfo* entryInfo = m_entryInfoMap[i];
148 BOOST_ASSERT(entryInfo->queueType ==
QUEUE_FIFO);
150 m_queues[
QUEUE_FIFO].erase(entryInfo->queueIt);
154 entryInfo->queueIt = queue.insert(queue.end(), i);
155 m_entryInfoMap[i] = entryInfo;
Represents a CS replacement policy.
Cs * getCs() const noexcept
Returns a pointer to the associated CS instance.
Table::const_iterator EntryRef
A reference to a CS entry.
size_t getLimit() const noexcept
Gets hard limit (in number of entries).
signal::Signal< Policy, EntryRef > beforeEvict
Signal emitted when an entry is being evicted.
Priority First-In-First-Out (FIFO) replacement policy.
~PriorityFifoPolicy() final
#define NFD_REGISTER_CS_POLICY(P)
Registers a CS policy.
std::list< Policy::EntryRef > Queue
ndn::Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.