28class EXPCL_PANDA_GOBJ SimpleLru :
public LinkedListNode,
public Namable {
30 explicit SimpleLru(
const std::string &name,
size_t max_size);
39 INLINE
void evict_to(
size_t target_size);
44 void output(std::ostream &out)
const;
45 void write(std::ostream &out,
int indent_level)
const;
51 void do_evict_to(
size_t target_size,
bool hard_evict);
56 SimpleLruPage *_active_marker;
58 friend class SimpleLruPage;
65class EXPCL_PANDA_GOBJ SimpleLruPage :
public LinkedListNode {
67 INLINE
explicit SimpleLruPage(
size_t lru_size);
68 INLINE SimpleLruPage(
const SimpleLruPage ©);
69 INLINE
void operator = (
const SimpleLruPage ©);
71 virtual ~SimpleLruPage();
73 INLINE SimpleLru *
get_lru()
const;
86 virtual void output(std::ostream &out)
const;
87 virtual void write(std::ostream &out,
int indent_level)
const;
94 friend class SimpleLru;
97inline std::ostream &operator << (std::ostream &out,
const SimpleLru &lru) {
102inline std::ostream &operator << (std::ostream &out,
const SimpleLruPage &page) {
This is a standard, non-reentrant mutex, similar to the Mutex class.
void output(std::ostream &out) const
Outputs the Namable.
One atomic piece that may be managed by a SimpleLru chain.
size_t get_lru_size() const
Returns the size of this page as reported to the LRU, presumably in bytes.
void dequeue_lru()
Removes the page from its SimpleLru.
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...
SimpleLru * get_lru() const
Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU.
void set_lru_size(size_t lru_size)
Specifies the size of this page, presumably in bytes, although any unit is possible.
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...
virtual void evict_lru()
Evicts the page from the LRU.
An implementation of a very simple LRU algorithm.
void begin_epoch()
Marks the end of the previous epoch and the beginning of the next one.
void evict_to(size_t target_size)
Evicts a sequence of objects until the queue fits within the indicated target size,...
void consider_evict()
Evicts a sequence of objects if the queue is full.
size_t get_max_size() const
Returns the max size of all objects that are allowed to be active on the LRU.
size_t count_active_size() const
Returns the total size of the pages that were enqueued since the last call to begin_epoch().
void set_max_size(size_t max_size)
Changes the max size of all objects that are allowed to be active on the LRU.
bool validate()
Checks that the LRU is internally self-consistent.
size_t get_total_size() const
Returns the total size of all objects currently active on the LRU.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.