14#ifndef VERTEXDATAPAGE_H
15#define VERTEXDATAPAGE_H
55 INLINE RamClass get_ram_class()
const;
56 INLINE RamClass get_pending_ram_class()
const;
57 INLINE
void request_resident();
64 INLINE
static SimpleLru *get_global_lru(RamClass rclass);
65 INLINE
static SimpleLru *get_pending_lru();
67 MAKE_PROPERTY(save_file, get_save_file);
69 INLINE
bool save_to_disk();
71 INLINE
static int get_num_threads();
72 INLINE
static int get_num_pending_reads();
73 INLINE
static int get_num_pending_writes();
74 static void stop_threads();
75 static void flush_threads();
77 virtual void output(std::ostream &out)
const;
78 virtual void write(std::ostream &out,
int indent_level)
const;
81 INLINE
unsigned char *get_page_data(
bool force);
86 virtual void changed_contiguous();
94 void make_resident_now();
96 void make_compressed();
99 bool do_save_to_disk();
100 void do_restore_from_disk();
102 void adjust_book_size();
104 void request_ram_class(RamClass ram_class);
105 INLINE
void set_ram_class(RamClass ram_class);
106 static void make_save_file();
108 INLINE
size_t round_up(
size_t page_size)
const;
109 unsigned char *alloc_page_data(
size_t page_size)
const;
110 void free_page_data(
unsigned char *page_data,
size_t page_size)
const;
114 class PageThreadManager;
115 class EXPCL_PANDA_GOBJ PageThread :
public Thread {
117 PageThread(PageThreadManager *manager,
const std::string &name);
120 virtual void thread_main();
123 PageThreadManager *_manager;
128 friend class PageThreadManager;
130 typedef pvector<PT(PageThread) > PageThreads;
132 class EXPCL_PANDA_GOBJ PageThreadManager :
public ReferenceCount {
134 PageThreadManager(
int num_threads);
137 int get_num_threads()
const;
138 int get_num_pending_reads()
const;
139 int get_num_pending_writes()
const;
140 void start_threads(
int num_threads);
144 PendingPages _pending_writes;
145 PendingPages _pending_reads;
152 PageThreads _threads;
153 friend class PageThread;
156 static PT(PageThreadManager) _thread_mgr;
157 static Mutex &_tlock;
159 unsigned char *_page_data;
160 size_t _size, _allocated_size, _uncompressed_size;
167 RamClass _pending_ram_class;
171 enum { deflate_page_size = 1024, inflate_page_size = 1024 };
175 class EXPCL_PANDA_GOBJ DeflatePage {
181 ALLOC_DELETED_CHAIN(DeflatePage);
183 unsigned char _buffer[deflate_page_size];
191 static void init_type() {
203 static SimpleLru *_global_lru[RC_end_of_list];
207 static Mutex _unused_mutex;
220 static void init_type() {
227 friend class PageThread;
231inline std::ostream &operator << (std::ostream &out,
const VertexDataPage &page) {
This class implements a condition variable; see ConditionVar for a brief introduction to this class.
A condition variable, usually used to communicate information about changing state to a thread that i...
A standard mutex, or mutual exclusion lock.
A lightweight class that represents a single element that may be timed and/or counted via stats.
A base class for all things that want to be reference-counted.
A single block as returned from SimpleAllocator::alloc().
An implementation of a very simple block allocator.
SimpleAllocatorBlock * get_first_block() const
Returns a pointer to the first allocated block, or NULL if there are no allocated blocks.
SimpleAllocatorBlock * alloc(size_t size, size_t alignment=1)
Allocates a new block.
One atomic piece that may be managed by a SimpleLru chain.
virtual void evict_lru()
Evicts the page from the LRU.
An implementation of a very simple LRU algorithm.
A thread; that is, a lightweight process.
TypeHandle is the identifier used to differentiate C++ class types.
A block of bytes that stores the actual raw vertex data referenced by a GeomVertexArrayData object.
A collection of VertexDataPages, which can be used to allocate new VertexDataBlock objects.
A block of bytes that holds one or more VertexDataBlocks.
A block of bytes on the save file.
A temporary file to hold the vertex data that has been evicted from memory and written to disk.
This is our own Panda specialization on the default STL deque.
This is our own Panda specialization on the default STL vector.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
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.