32 namespace priority_fifo {
44 for (
auto entryInfoMapPair : m_entryInfoMap) {
45 delete entryInfoMapPair.second;
50 PriorityFifoPolicy::doAfterInsert(EntryRef i)
57 PriorityFifoPolicy::doAfterRefresh(EntryRef i)
64 PriorityFifoPolicy::doBeforeErase(EntryRef i)
70 PriorityFifoPolicy::doBeforeUse(EntryRef i)
72 BOOST_ASSERT(m_entryInfoMap.find(i) != m_entryInfoMap.end());
76 PriorityFifoPolicy::evictEntries()
78 BOOST_ASSERT(this->
getCs() !=
nullptr);
86 PriorityFifoPolicy::evictOne()
103 this->detachQueue(i);
108 PriorityFifoPolicy::attachQueue(EntryRef i)
110 BOOST_ASSERT(m_entryInfoMap.find(i) == m_entryInfoMap.end());
112 EntryInfo* entryInfo =
new EntryInfo();
113 if (i->isUnsolicited()) {
116 else if (!i->isFresh()) {
121 entryInfo->moveStaleEventId =
getScheduler().schedule(i->getData().getFreshnessPeriod(),
122 [=] { moveToStaleQueue(i); });
125 Queue& queue = m_queues[entryInfo->queueType];
126 entryInfo->queueIt = queue.insert(queue.end(), i);
127 m_entryInfoMap[i] = entryInfo;
131 PriorityFifoPolicy::detachQueue(EntryRef i)
133 BOOST_ASSERT(m_entryInfoMap.find(i) != m_entryInfoMap.end());
135 EntryInfo* entryInfo = m_entryInfoMap[i];
137 entryInfo->moveStaleEventId.cancel();
140 m_queues[entryInfo->queueType].erase(entryInfo->queueIt);
141 m_entryInfoMap.erase(i);
146 PriorityFifoPolicy::moveToStaleQueue(EntryRef i)
148 BOOST_ASSERT(m_entryInfoMap.find(i) != m_entryInfoMap.end());
150 EntryInfo* entryInfo = m_entryInfoMap[i];
151 BOOST_ASSERT(entryInfo->queueType ==
QUEUE_FIFO);
153 m_queues[
QUEUE_FIFO].erase(entryInfo->queueIt);
157 entryInfo->queueIt = queue.insert(queue.end(), i);
158 m_entryInfoMap[i] = entryInfo;