cs-policy-priority-fifo.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_TABLE_CS_POLICY_FIFO_HPP
27 #define NFD_DAEMON_TABLE_CS_POLICY_FIFO_HPP
28 
29 #include "cs-policy.hpp"
30 #include "core/scheduler.hpp"
31 
32 namespace nfd {
33 namespace cs {
34 namespace priority_fifo {
35 
36 typedef std::list<iterator> Queue;
38 
39 enum QueueType {
44 };
45 
46 struct EntryInfo
47 {
49  QueueIt queueIt;
50  scheduler::EventId moveStaleEventId;
51 };
52 
54 {
55  bool
56  operator()(const iterator& a, const iterator& b) const
57  {
58  return *a < *b;
59  }
60 };
61 
62 typedef std::map<iterator, EntryInfo*, EntryItComparator> EntryInfoMapFifo;
63 
72 class PriorityFifoPolicy : public Policy
73 {
74 public:
76 
77  virtual
79 
80 public:
81  static const std::string POLICY_NAME;
82 
83 private:
84  virtual void
85  doAfterInsert(iterator i) override;
86 
87  virtual void
88  doAfterRefresh(iterator i) override;
89 
90  virtual void
91  doBeforeErase(iterator i) override;
92 
93  virtual void
94  doBeforeUse(iterator i) override;
95 
96  virtual void
97  evictEntries() override;
98 
99 private:
103  void
104  evictOne();
105 
109  void
110  attachQueue(iterator i);
111 
115  void
116  detachQueue(iterator i);
117 
120  void
121  moveToStaleQueue(iterator i);
122 
123 private:
124  Queue m_queues[QUEUE_MAX];
125  EntryInfoMapFifo m_entryInfoMap;
126 };
127 
128 } // namespace priority_fifo
129 
131 
132 } // namespace cs
133 } // namespace nfd
134 
135 #endif // NFD_DAEMON_TABLE_CS_POLICY_FIFO_HPP
QueueIt queueIt
Priority Fifo cs replacement policy.
bool operator()(const iterator &a, const iterator &b) const
scheduler::EventId moveStaleEventId
Table::const_iterator iterator
Definition: cs-internal.hpp:41
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
represents a CS replacement policy
Definition: cs-policy.hpp:39
QueueType queueType
std::map< iterator, EntryInfo *, EntryItComparator > EntryInfoMapFifo