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());
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;
Cs * getCs() const
gets cs
NFD_REGISTER_CS_POLICY(PriorityFifoPolicy)
#define emitSignal(...)
(implementation detail)
Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.
represents a CS replacement policy
std::list< Policy::EntryRef > Queue
Copyright (c) 2011-2015 Regents of the University of California.
Table::const_iterator EntryRef
a reference to an CS entry
static const std::string POLICY_NAME
signal::Signal< Policy, EntryRef > beforeEvict
emits when an entry is being evicted
span_constexpr std::size_t size(span< T, Extent > const &spn)
size_t getLimit() const
gets hard limit (in number of entries)
Priority FIFO replacement policy.
~PriorityFifoPolicy() final