47 explicit AdaptiveLru(
const std::string &name,
size_t max_size);
50 INLINE
size_t get_total_size()
const;
51 INLINE
size_t get_max_size()
const;
52 INLINE
void set_max_size(
size_t max_size);
53 size_t count_active_size()
const;
55 INLINE
void consider_evict();
56 INLINE
void evict_to(
size_t target_size);
59 INLINE
bool validate();
61 void output(std::ostream &out)
const;
62 void write(std::ostream &out,
int indent_level)
const;
67 INLINE
void set_weight(PN_stdfloat weight);
68 INLINE PN_stdfloat get_weight()
const;
70 INLINE
void set_max_updates_per_frame(
int max_updates_per_frame);
71 INLINE
int get_max_updates_per_frame()
const;
75 enum LruPagePriority {
80 LPP_Intermediate = 30,
82 LPP_TotalPriorities = 50,
85 INLINE PN_stdfloat calculate_exponential_moving_average(PN_stdfloat value, PN_stdfloat average)
const;
87 void do_partial_lru_update(
int num_updates);
94 void do_evict_to(
size_t target_size,
bool hard_evict);
102 unsigned int _current_frame_identifier;
104 int _max_updates_per_frame;
146 INLINE
void dequeue_lru();
148 INLINE
void mark_used_lru()
const;
151 INLINE
size_t get_lru_size()
const;
152 INLINE
void set_lru_size(
size_t lru_size);
154 virtual void evict_lru();
156 virtual void output(std::ostream &out)
const;
157 virtual void write(std::ostream &out,
int indent_level)
const;
160 unsigned int get_num_frames()
const;
161 unsigned int get_num_inactive_frames()
const;
169 unsigned int _first_frame_identifier;
170 unsigned int _current_frame_identifier;
171 unsigned int _update_frame_identifier;
173 int _current_frame_usage;
174 int _last_frame_usage;
175 int _update_total_usage;
177 PN_stdfloat _average_frame_utilization;
182 inline std::ostream &operator << (std::ostream &out,
const AdaptiveLru &lru) {
187 inline std::ostream &operator << (std::ostream &out,
const AdaptiveLruPage &page) {
194 void test_adaptive_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.
This just stores the pointers to implement a doubly-linked list of some kind of object.
void output(std::ostream &out) const
Outputs the Namable.
A base class for all things which can have a name.
One atomic piece that may be managed by a AdaptiveLru chain.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic LRU-type algorithm, except that it is adaptive and attempts to avoid evicting pages that have...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a standard, non-reentrant mutex, similar to the Mutex class.