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