23 PStatCollector GeomCacheManager::_geom_cache_size_pcollector(
"Geom cache size");
24 PStatCollector GeomCacheManager::_geom_cache_active_pcollector(
"Geom cache size:Active");
25 PStatCollector GeomCacheManager::_geom_cache_record_pcollector(
"Geom cache operations:record");
26 PStatCollector GeomCacheManager::_geom_cache_erase_pcollector(
"Geom cache operations:erase");
27 PStatCollector GeomCacheManager::_geom_cache_evict_pcollector(
"Geom cache operations:evict");
34 _lock(
"GeomCacheManager"),
50 nassert_raise(
"attempt to delete GeomCacheManager");
70 if (_global_ptr ==
nullptr) {
84 int min_frames = geom_cache_min_frames;
86 while (_total_size > max_size) {
88 nassertv(entry != _list);
90 if (keep_current && current_frame - entry->_last_frame_used < min_frames) {
92 if (gobj_cat.is_debug()) {
94 <<
"Oldest element in cache is " 95 << current_frame - entry->_last_frame_used
96 <<
" frames; keeping cache at " << _total_size <<
" entries.\n";
103 if (gobj_cat.is_debug()) {
105 <<
"cache total_size = " << _total_size <<
" entries, max_size = " 106 << max_size <<
", removing " << *entry <<
"\n";
109 entry->evict_callback();
112 if (entry->_last_frame_used == current_frame) {
113 GeomCacheManager::_geom_cache_active_pcollector.sub_level(1);
118 entry->remove_from_list();
119 _geom_cache_evict_pcollector.add_level(1);
121 _geom_cache_size_pcollector.set_level(_total_size);
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight class that represents a single element that may be timed and/or counted via stats.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_frame_count
Returns the number of times tick() has been called since the ClockObject was created,...
Similar to MutexHolder, but for a light mutex.
This is used to keep track of, and limit the size of, the cache of munged vertices,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void flush()
Immediately empties all elements in the cache.
Similar to MutexHolder, but for a light reentrant mutex.
void ref() const
Explicitly increments the reference count.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void evict_old_entries()
Trims the cache size down to get_max_size() by evicting old cache entries as needed.
static bool is_connected()
Returns true if the client believes it is connected to a working PStatServer, false otherwise.
This object contains a single cache entry in the GeomCacheManager.
static GeomCacheManager * get_global_ptr()
Returns the global cache manager pointer.