hpx/cache/entries/lru_entry.hpp
hpx/cache/entries/lru_entry.hpp#
Defined in header hpx/cache/entries/lru_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 lru_entry : public hpx::util::cache::entries::entry<Value, lru_entry<Value>># - #include <hpx/cache/entries/lru_entry.hpp>
The lru_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 used entries are discarded from the cache first.
Note
The lru_entry conforms to the CacheEntry concept.
Note
This type can be used to model a ‘most recently used’ 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
-
inline lru_entry()#
Any cache entry has to be default constructible.
-
inline explicit lru_entry(Value const &val) noexcept(std::is_nothrow_constructible_v<base_type, Value const&>)#
Construct a new instance of a cache entry holding the given value.
-
inline explicit lru_entry(Value &&val) noexcept#
Construct a new instance of a cache entry holding the given value.
-
inline bool touch()#
The function touch is called by a cache holding this instance whenever it has been requested (touched).
In the case of the LRU entry we store the time of the last access which will be used to compare the age of an entry during the invocation of the operator<().
- Returns
This function should return true if the cache needs to update it’s internal heap. Usually this is needed if the entry has been changed by touch() in a way influencing the sort order as mandated by the cache’s UpdatePolicy
-
inline constexpr time_point const &get_access_time() const noexcept#
Returns the last access time of the entry.
Private Types
Private Members
-
time_point access_time_#
Friends
-
inline friend bool operator<(lru_entry const &lhs, lru_entry const &rhs) noexcept(noexcept(std::declval<time_point const&>() < std::declval<time_point const&>()))#
Compare the ‘age’ of two entries. An entry is ‘older’ than another entry if it has been accessed less recently (LRU).
-
template<typename Value>
-
namespace entries
-
namespace cache
-
namespace util