nfd::cs::priority_fifo::PriorityFifoPolicy Class Referencefinal

Priority First-In-First-Out (FIFO) replacement policy. More...

#include <daemon/table/cs-policy-priority-fifo.hpp>

+ Inheritance diagram for nfd::cs::priority_fifo::PriorityFifoPolicy:
+ Collaboration diagram for nfd::cs::priority_fifo::PriorityFifoPolicy:

Public Types

using EntryRef = Table::const_iterator
 A reference to a CS entry. More...
 

Public Member Functions

 PriorityFifoPolicy ()
 
 ~PriorityFifoPolicy () final
 
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...
 
CsgetCs () const noexcept
 Returns a pointer to the associated CS instance. More...
 
size_t getLimit () const noexcept
 Gets hard limit (in number of entries). More...
 
const std::string & getName () const noexcept
 
void setCs (Cs *cs) noexcept
 Sets the associated CS instance. More...
 
void setLimit (size_t nMaxEntries)
 Sets hard limit (in number of entries). More...
 

Static Public Member Functions

static unique_ptr< Policycreate (const std::string &policyName)
 Returns a cs::Policy identified by policyName, or nullptr if policyName is unknown. More...
 
static std::set< std::string > getPolicyNames ()
 Returns a list of available policy names. More...
 
template<typename P >
static void registerPolicy (const std::string &policyName=P::POLICY_NAME)
 

Public Attributes

signal::Signal< Policy, EntryRefbeforeEvict
 Signal emitted when an entry is being evicted. More...
 

Static Public Attributes

static const std::string POLICY_NAME = "priority_fifo"
 

Detailed Description

Priority First-In-First-Out (FIFO) replacement policy.

This policy maintains a set of cleanup queues to decide the eviction order of CS entries. The cleanup queues are three doubly linked lists that store EntryRefs. The three queues keep track of unsolicited, stale, and fresh Data packet, respectively. EntryRef is placed into, removed from, and moved between suitable queues whenever an Entry is added, removed, or has other attribute changes. Each Entry should be in exactly one queue at any moment. Within each queue, the EntryRefs are kept in first-in-first-out order. Eviction procedure exhausts the first queue before moving onto the next queue, in the order of unsolicited, stale, and fresh queue.

Definition at line 64 of file cs-policy-priority-fifo.hpp.

Member Typedef Documentation

◆ EntryRef

using nfd::cs::Policy::EntryRef = Table::const_iterator
inherited

A reference to a CS entry.

Note
operator< of EntryRef compares the Data name enclosed in the Entry.

Definition at line 113 of file cs-policy.hpp.

Constructor & Destructor Documentation

◆ PriorityFifoPolicy()

nfd::cs::priority_fifo::PriorityFifoPolicy::PriorityFifoPolicy ( )

Definition at line 35 of file cs-policy-priority-fifo.cpp.

◆ ~PriorityFifoPolicy()

nfd::cs::priority_fifo::PriorityFifoPolicy::~PriorityFifoPolicy ( )
final

Definition at line 40 of file cs-policy-priority-fifo.cpp.

Member Function Documentation

◆ afterInsert()

void nfd::cs::Policy::afterInsert ( EntryRef  i)
inherited

Invoked by CS after a new entry is inserted.

Postcondition
cs.size() <= getLimit()

The policy may evict entries if necessary. During this process, i might be evicted.

Definition at line 75 of file cs-policy.cpp.

◆ afterRefresh()

void nfd::cs::Policy::afterRefresh ( EntryRef  i)
inherited

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 82 of file cs-policy.cpp.

◆ beforeErase()

void nfd::cs::Policy::beforeErase ( EntryRef  i)
inherited

Invoked by CS before an entry is erased due to management command.

Warning
CS must not invoke this method if an entry is erased due to eviction.

Definition at line 89 of file cs-policy.cpp.

◆ beforeUse()

void nfd::cs::Policy::beforeUse ( EntryRef  i)
inherited

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 96 of file cs-policy.cpp.

◆ create()

unique_ptr< Policy > nfd::cs::Policy::create ( const std::string &  policyName)
staticinherited

Returns a cs::Policy identified by policyName, or nullptr if policyName is unknown.

Definition at line 45 of file cs-policy.cpp.

◆ getCs()

Cs* nfd::cs::Policy::getCs ( ) const
inlinenoexceptinherited

Returns a pointer to the associated CS instance.

Definition at line 77 of file cs-policy.hpp.

◆ getLimit()

size_t nfd::cs::Policy::getLimit ( ) const
inlinenoexceptinherited

Gets hard limit (in number of entries).

Definition at line 95 of file cs-policy.hpp.

◆ getName()

const std::string& nfd::cs::Policy::getName ( ) const
inlinenoexceptinherited

Definition at line 68 of file cs-policy.hpp.

◆ getPolicyNames()

std::set< std::string > nfd::cs::Policy::getPolicyNames ( )
staticinherited

Returns a list of available policy names.

Definition at line 53 of file cs-policy.cpp.

◆ registerPolicy()

template<typename P >
static void nfd::cs::Policy::registerPolicy ( const std::string &  policyName = P::POLICY_NAME)
inlinestaticinherited

Definition at line 43 of file cs-policy.hpp.

◆ setCs()

void nfd::cs::Policy::setCs ( Cs cs)
inlinenoexceptinherited

Sets the associated CS instance.

Definition at line 86 of file cs-policy.hpp.

◆ setLimit()

void nfd::cs::Policy::setLimit ( size_t  nMaxEntries)
inherited

Sets hard limit (in number of entries).

Postcondition
getLimit() == nMaxEntries
cs.size() <= getLimit()

The policy may evict entries if necessary.

Definition at line 67 of file cs-policy.cpp.

Member Data Documentation

◆ beforeEvict

signal::Signal<Policy, EntryRef> nfd::cs::Policy::beforeEvict
inherited

Signal emitted 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 120 of file cs-policy.hpp.

◆ POLICY_NAME

const std::string nfd::cs::priority_fifo::PriorityFifoPolicy::POLICY_NAME = "priority_fifo"
static

Definition at line 72 of file cs-policy-priority-fifo.hpp.