43 if (_total_size > _max_size) {
44 do_evict_to(_max_size,
false);
54 if (_total_size > _max_size) {
55 do_evict_to(_max_size,
false);
66 if (_total_size > target_size) {
67 do_evict_to(target_size,
true);
95 INLINE SimpleLruPage::
96 SimpleLruPage(
size_t lru_size) :
105 INLINE SimpleLruPage::
108 _lru_size(copy._lru_size)
115 INLINE
void SimpleLruPage::
137 if (_lru !=
nullptr) {
139 _lru->_total_size -= _lru_size;
153 if (_lru !=
nullptr) {
182 if (_lru !=
nullptr) {
183 _lru->_total_size -= _lru_size;
184 _lru->_total_size += lru_size;
185 _lru_size = lru_size;
187 _lru_size = lru_size;
size_t get_total_size() const
Returns the total size of all objects currently active on the LRU.
void consider_evict()
Evicts a sequence of objects if the queue is full.
An implementation of a very simple LRU algorithm.
void mark_used_lru() const
To be called when the page is used; this will move it to the tail of the SimpleLru queue it is alread...
void enqueue_lru(SimpleLru *lru)
Adds the page to the LRU for the first time, or marks it recently-accessed if it has already been add...
void dequeue_lru()
Removes the page from its SimpleLru.
void begin_epoch()
Marks the end of the previous epoch and the beginning of the next one.
size_t get_lru_size() const
Returns the size of this page as reported to the LRU, presumably in bytes.
void set_lru_size(size_t lru_size)
Specifies the size of this page, presumably in bytes, although any unit is possible.
Similar to MutexHolder, but for a light mutex.
One atomic piece that may be managed by a SimpleLru chain.
void evict_to(size_t target_size)
Evicts a sequence of objects until the queue fits within the indicated target size,...
void set_max_size(size_t max_size)
Changes the max size of all objects that are allowed to be active on the LRU.
size_t get_max_size() const
Returns the max size of all objects that are allowed to be active on the LRU.
SimpleLru * get_lru() const
Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU.
bool validate()
Checks that the LRU is internally self-consistent.