Panda3D
panda
src
gobj
geomCacheManager.h
Go to the documentation of this file.
1
/**
2
* PANDA 3D SOFTWARE
3
* Copyright (c) Carnegie Mellon University. All rights reserved.
4
*
5
* All use of this software is subject to the terms of the revised BSD
6
* license. You should have received a copy of this license along
7
* with this source code in a file named "LICENSE."
8
*
9
* @file geomCacheManager.h
10
* @author drose
11
* @date 2005-03-11
12
*/
13
14
#ifndef GEOMCACHEMANAGER_H
15
#define GEOMCACHEMANAGER_H
16
17
#include "
pandabase.h
"
18
#include "
config_gobj.h
"
19
#include "
lightMutex.h
"
20
#include "
pStatCollector.h
"
21
22
class
GeomCacheEntry
;
23
24
/**
25
* This is used to keep track of, and limit the size of, the cache of munged
26
* vertices, which would otherwise be distributed through all of the
27
* GeomVertexData objects in the system.
28
*
29
* The actual data in the cache is not stored here, but rather it is
30
* distributed among the various GeomVertexData source objects. This allows
31
* the cache data to propagate through the multiprocess pipeline.
32
*
33
* This structure actually caches any of a number of different types of
34
* pointers, and mixes them all up in the same LRU cache list. Some of them
35
* (such as GeomMunger) are reference-counted here in the cache; most are not.
36
*/
37
class
EXPCL_PANDA_GOBJ
GeomCacheManager
{
38
protected
:
39
GeomCacheManager
();
40
~
GeomCacheManager
();
41
42
PUBLISHED:
43
INLINE
void
set_max_size(
int
max_size)
const
;
44
INLINE
int
get_max_size()
const
;
45
46
INLINE
int
get_total_size()
const
;
47
48
void
flush();
49
50
static
GeomCacheManager
*get_global_ptr();
51
52
public
:
53
INLINE
void
evict_old_entries();
54
void
evict_old_entries(
int
max_size,
bool
keep_current);
55
INLINE
static
void
flush_level();
56
57
private
:
58
// This mutex protects all operations on this object, especially the linked-
59
// list operations.
60
LightMutex
_lock;
61
62
int
_total_size;
63
64
// We maintain a doubly-linked list to keep the cache entries in least-
65
// recently-used order: the items at the head of the list are ready to be
66
// flushed. We use our own doubly-linked list instead of an STL list, just
67
// so we can avoid a tiny bit of overhead, especially in keeping the pointer
68
// directly into the list from the calling objects.
69
70
// The tail and the head of the list are both kept by the _prev and _next
71
// pointers, respectively, within the following object, which always exists
72
// solely to keep a handle to the list. Keeping a token of the list this
73
// way avoids special cases for an empty list.
74
GeomCacheEntry
*_list;
75
76
static
GeomCacheManager
*_global_ptr;
77
78
public
:
79
static
PStatCollector
_geom_cache_size_pcollector;
80
static
PStatCollector
_geom_cache_active_pcollector;
81
static
PStatCollector
_geom_cache_record_pcollector;
82
static
PStatCollector
_geom_cache_erase_pcollector;
83
static
PStatCollector
_geom_cache_evict_pcollector;
84
85
friend
class
GeomCacheEntry
;
86
};
87
88
#include "
geomCacheManager.I
"
89
90
#endif
GeomCacheEntry
This object contains a single cache entry in the GeomCacheManager.
Definition:
geomCacheEntry.h:31
GeomCacheManager
This is used to keep track of, and limit the size of, the cache of munged vertices,...
Definition:
geomCacheManager.h:37
LightMutex
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition:
lightMutex.h:41
PStatCollector
A lightweight class that represents a single element that may be timed and/or counted via stats.
Definition:
pStatCollector.h:43
config_gobj.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geomCacheManager.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lightMutex.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatCollector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Generated on Tue Aug 31 2021 11:10:03 for Panda3D by
1.9.1