represents a CS replacement policy More...
#include <cs-policy.hpp>
Public Types | |
using | EntryRef = Table::const_iterator |
a reference to an CS entry More... | |
Public Member Functions | |
Policy (const std::string &policyName) | |
virtual | ~Policy ()=default |
const std::string & | getName () const |
Cs * | getCs () const |
gets cs More... | |
void | setCs (Cs *cs) |
sets cs More... | |
size_t | getLimit () const |
gets hard limit (in number of entries) More... | |
void | setLimit (size_t nMaxEntries) |
sets hard limit (in number of entries) More... | |
void | afterInsert (EntryRef i) |
invoked by CS after a new entry is inserted More... | |
void | afterRefresh (EntryRef i) |
invoked by CS after an existing entry is refreshed by same Data More... | |
void | beforeErase (EntryRef i) |
invoked by CS before an entry is erased due to management command More... | |
void | beforeUse (EntryRef i) |
invoked by CS before an entry is used to match a lookup More... | |
Static Public Member Functions | |
template<typename P > | |
static void | registerPolicy (const std::string &policyName=P::POLICY_NAME) |
static unique_ptr< Policy > | create (const std::string &policyName) |
static std::set< std::string > | getPolicyNames () |
Public Attributes | |
signal::Signal< Policy, EntryRef > | beforeEvict |
emits when an entry is being evicted More... | |
Protected Member Functions | |
virtual void | doAfterInsert (EntryRef i)=0 |
invoked after a new entry is created in CS More... | |
virtual void | doAfterRefresh (EntryRef i)=0 |
invoked after an existing entry is refreshed by same Data More... | |
virtual void | doBeforeErase (EntryRef i)=0 |
invoked before an entry is erased due to management command More... | |
virtual void | doBeforeUse (EntryRef i)=0 |
invoked before an entry is used to match a lookup More... | |
virtual void | evictEntries ()=0 |
evicts zero or more entries More... | |
represents a CS replacement policy
Definition at line 38 of file cs-policy.hpp.
using nfd::cs::Policy::EntryRef = Table::const_iterator |
a reference to an CS entry
Definition at line 111 of file cs-policy.hpp.
|
explicit |
Definition at line 62 of file cs-policy.cpp.
Referenced by registerPolicy().
|
virtualdefault |
Referenced by registerPolicy().
|
inlinestatic |
Definition at line 43 of file cs-policy.hpp.
References create(), getPolicyNames(), Policy(), and ~Policy().
|
static |
policyName
, or nullptr if policyName
is unknown Definition at line 46 of file cs-policy.cpp.
Referenced by nfd::TablesConfigSection::ensureConfigured(), nfd::cs::makeDefaultPolicy(), and registerPolicy().
|
static |
Definition at line 54 of file cs-policy.cpp.
Referenced by registerPolicy().
|
inline |
Definition at line 69 of file cs-policy.hpp.
|
inline |
gets cs
Definition at line 77 of file cs-policy.hpp.
Referenced by nfd::cs::lru::LruPolicy::LruPolicy(), and nfd::cs::priority_fifo::PriorityFifoPolicy::~PriorityFifoPolicy().
|
inline |
sets cs
Definition at line 85 of file cs-policy.hpp.
|
inline |
gets hard limit (in number of entries)
Definition at line 93 of file cs-policy.hpp.
References setLimit().
Referenced by nfd::cs::lru::LruPolicy::LruPolicy(), and nfd::cs::priority_fifo::PriorityFifoPolicy::~PriorityFifoPolicy().
void nfd::cs::Policy::setLimit | ( | size_t | nMaxEntries | ) |
sets hard limit (in number of entries)
The policy may evict entries if necessary.
Definition at line 68 of file cs-policy.cpp.
References evictEntries(), and NFD_LOG_INFO.
Referenced by getLimit().
void nfd::cs::Policy::afterInsert | ( | EntryRef | i | ) |
invoked by CS after a new entry is inserted
The policy may evict entries if necessary. During this process, i
might be evicted.
Definition at line 76 of file cs-policy.cpp.
References doAfterInsert().
void nfd::cs::Policy::afterRefresh | ( | EntryRef | i | ) |
invoked by CS after an existing entry is refreshed by same Data
The policy may witness this refresh to make better eviction decisions in the future.
Definition at line 83 of file cs-policy.cpp.
References doAfterRefresh().
void nfd::cs::Policy::beforeErase | ( | EntryRef | i | ) |
invoked by CS before an entry is erased due to management command
Definition at line 90 of file cs-policy.cpp.
References doBeforeErase().
void nfd::cs::Policy::beforeUse | ( | EntryRef | i | ) |
invoked by CS before an entry is used to match a lookup
The policy may witness this usage to make better eviction decisions in the future.
Definition at line 97 of file cs-policy.cpp.
References doBeforeUse().
|
protectedpure virtual |
invoked after a new entry is created in CS
When overridden in a subclass, a policy implementation should decide whether to accept i
. If i
is accepted, it should be inserted into a cleanup index. Otherwise, beforeEvict
signal should be emitted with i
to inform CS to erase the entry. A policy implementation may decide to evict other entries by emitting beforeEvict
signal, in order to keep CS size under limit.
Referenced by afterInsert().
|
protectedpure virtual |
invoked after an existing entry is refreshed by same Data
When overridden in a subclass, a policy implementation may witness this operation and adjust its cleanup index.
Referenced by afterRefresh().
|
protectedpure virtual |
invoked before an entry is erased due to management command
When overridden in a subclass, a policy implementation should erase i
from its cleanup index without emitted afterErase
signal.
Referenced by beforeErase().
|
protectedpure virtual |
invoked before an entry is used to match a lookup
When overridden in a subclass, a policy implementation may witness this operation and adjust its cleanup index.
Referenced by beforeUse().
|
protectedpure virtual |
evicts zero or more entries
Referenced by setLimit().
signal::Signal<Policy, EntryRef> nfd::cs::Policy::beforeEvict |
emits when an entry is being evicted
A policy implementation should emit this signal to cause CS to erase an entry from its index. CS should connect to this signal and erase the entry upon signal emission.
Definition at line 118 of file cs-policy.hpp.
Referenced by nfd::cs::lru::LruPolicy::LruPolicy(), and nfd::cs::priority_fifo::PriorityFifoPolicy::~PriorityFifoPolicy().