hpx/cache/entries/fifo_entry.hpp

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace util
namespace cache
namespace entries
template<typename Value>
class fifo_entry : public hpx::util::cache::entries::entry<Value, fifo_entry<Value>>
#include <hpx/cache/entries/fifo_entry.hpp>

The fifo_entry type can be used to store arbitrary values in a cache. Using this type as the cache’s entry type makes sure that the least recently inserted entries are discarded from the cache first.

Note

The fifo_entry conforms to the CacheEntry concept.

Note

This type can be used to model a ‘last in first out’ cache policy if it is used with a std::greater as the caches’ UpdatePolicy (instead of the default std::less).

Template Parameters
  • Value: The data type to be stored in a cache. It has to be default constructible, copy constructible and less_than_comparable.

Public Functions

fifo_entry()

Any cache entry has to be default constructible.

fifo_entry(Value const &val)

Construct a new instance of a cache entry holding the given value.

fifo_entry(Value &&val)

Construct a new instance of a cache entry holding the given value.

constexpr bool insert()

The function insert is called by a cache whenever it is about to be inserted into the cache.

Note

This function is part of the CacheEntry concept

Return

This function should return true if the entry should be added to the cache, otherwise it should return false.

constexpr time_point const &get_creation_time() const

Private Types

template<>
using base_type = entry<Value, fifo_entry<Value>>
template<>
using time_point = std::chrono::steady_clock::time_point

Private Members

time_point insertion_time_

Friends

bool operator<(fifo_entry const &lhs, fifo_entry const &rhs)

Compare the ‘age’ of two entries. An entry is ‘older’ than another entry if it has been created earlier (FIFO).