Panda3D
|
A block of bytes that holds one or more VertexDataBlocks. More...
#include "vertexDataPage.h"
Classes | |
class | DeflatePage |
class | PageThread |
class | PageThreadManager |
Public Types | |
enum | RamClass { RC_resident, RC_compressed, RC_disk, RC_end_of_list } |
Public Member Functions | |
VertexDataBlock * | alloc (size_t size) |
Allocates a new block. | |
VertexDataBook * | get_book () const |
Returns a pointer to the book that owns this page. | |
VertexDataBlock * | get_first_block () const |
Returns a pointer to the first allocated block, or NULL if there are no allocated blocks. | |
unsigned char * | get_page_data (bool force) |
Returns a pointer to the page's data area, or NULL if the page is not currently resident. | |
RamClass | get_pending_ram_class () const |
Returns the pending ram class of the array. | |
RamClass | get_ram_class () const |
Returns the current ram class of the array. | |
bool | operator< (const VertexDataPage &other) const |
This comparison method is used to order pages within a book. | |
virtual void | output (ostream &out) const |
void | request_resident () |
Ensures that the page will become resident soon. | |
bool | save_to_disk () |
Writes the page to disk, but does not evict it from memory or affect its LRU status. | |
virtual void | write (ostream &out, int indent_level) const |
Static Public Member Functions | |
static void | flush_threads () |
Waits for all of the pending thread tasks to finish before returning. | |
static TypeHandle | get_class_type () |
static SimpleLru * | get_global_lru (RamClass rclass) |
Returns a pointer to the global LRU object that manages the VertexDataPage's with the indicated RamClass. | |
static int | get_num_pending_reads () |
Returns the number of read requests that are waiting to be serviced by a thread. | |
static int | get_num_pending_writes () |
Returns the number of write requests that are waiting to be serviced by a thread. | |
static int | get_num_threads () |
Returns the number of threads that have been spawned to service vertex paging requests, or 0 if no threads have been spawned (which may mean either that all paging requests will be handled by the main thread, or simply that no paging requests have yet been issued). | |
static SimpleLru * | get_pending_lru () |
Returns a pointer to the global LRU object that manages the VertexDataPage's that are pending processing by the thread. | |
static VertexDataSaveFile * | get_save_file () |
Returns the global VertexDataSaveFile that will be used to save vertex data buffers to disk when necessary. | |
static void | init_type () |
static void | stop_threads () |
Call this to stop the paging threads, if they were started. | |
Protected Member Functions | |
virtual void | changed_contiguous () |
This callback function is made whenever the estimate of contiguous available space changes, either through an alloc or free. | |
virtual void | evict_lru () |
Evicts the page from the LRU. | |
virtual SimpleAllocatorBlock * | make_block (size_t start, size_t size) |
Creates a new SimpleAllocatorBlock object. | |
Friends | |
class | PageThread |
class | VertexDataBook |
A block of bytes that holds one or more VertexDataBlocks.
The entire page may be paged out, in the form of in-memory compression or to an on-disk cache file, if necessary.
Definition at line 40 of file vertexDataPage.h.
VertexDataBlock * VertexDataPage::alloc | ( | size_t | size | ) | [inline] |
Allocates a new block.
Returns NULL if a block of the requested size cannot be allocated.
To free the allocated block, call block->free(), or simply delete the block pointer.
Reimplemented from SimpleAllocator.
Definition at line 68 of file vertexDataPage.I.
void VertexDataPage::changed_contiguous | ( | ) | [protected, virtual] |
This callback function is made whenever the estimate of contiguous available space changes, either through an alloc or free.
The lock will be held.
Reimplemented from SimpleAllocator.
Definition at line 262 of file vertexDataPage.cxx.
References SimpleAllocator::do_is_empty().
void VertexDataPage::evict_lru | ( | ) | [protected, virtual] |
Evicts the page from the LRU.
Called internally when the LRU determines that it is full. May also be called externally when necessary to explicitly evict the page.
It is legal for this method to either evict the page as requested, do nothing (in which case the eviction will be requested again at the next epoch), or requeue itself on the tail of the queue (in which case the eviction will be requested again much later).
Reimplemented from SimpleLruPage.
Definition at line 292 of file vertexDataPage.cxx.
References SimpleLru::get_max_size().
void VertexDataPage::flush_threads | ( | ) | [static] |
Waits for all of the pending thread tasks to finish before returning.
Definition at line 203 of file vertexDataPage.cxx.
References stop_threads().
VertexDataBook * VertexDataPage::get_book | ( | ) | const [inline] |
Returns a pointer to the book that owns this page.
Definition at line 91 of file vertexDataPage.I.
VertexDataBlock * VertexDataPage::get_first_block | ( | ) | const [inline] |
Returns a pointer to the first allocated block, or NULL if there are no allocated blocks.
Reimplemented from SimpleAllocator.
Definition at line 80 of file vertexDataPage.I.
SimpleLru * VertexDataPage::get_global_lru | ( | RamClass | rclass | ) | [inline, static] |
Returns a pointer to the global LRU object that manages the VertexDataPage's with the indicated RamClass.
Definition at line 103 of file vertexDataPage.I.
Referenced by GeomVertexArrayData::lru_epoch(), and GraphicsEngine::render_frame().
int VertexDataPage::get_num_pending_reads | ( | ) | [inline, static] |
Returns the number of read requests that are waiting to be serviced by a thread.
Definition at line 175 of file vertexDataPage.I.
int VertexDataPage::get_num_pending_writes | ( | ) | [inline, static] |
Returns the number of write requests that are waiting to be serviced by a thread.
Definition at line 190 of file vertexDataPage.I.
int VertexDataPage::get_num_threads | ( | ) | [inline, static] |
Returns the number of threads that have been spawned to service vertex paging requests, or 0 if no threads have been spawned (which may mean either that all paging requests will be handled by the main thread, or simply that no paging requests have yet been issued).
Definition at line 160 of file vertexDataPage.I.
unsigned char * VertexDataPage::get_page_data | ( | bool | force | ) | [inline] |
Returns a pointer to the page's data area, or NULL if the page is not currently resident.
If the page is not currently resident, this will implicitly request it to become resident soon.
If force is true, this method will never return NULL, but may block until the page is available.
Definition at line 210 of file vertexDataPage.I.
References SimpleLruPage::mark_used_lru().
Referenced by VertexDataBlock::get_pointer().
SimpleLru * VertexDataPage::get_pending_lru | ( | ) | [inline, static] |
Returns a pointer to the global LRU object that manages the VertexDataPage's that are pending processing by the thread.
Definition at line 116 of file vertexDataPage.I.
Referenced by GraphicsEngine::render_frame().
VertexDataPage::RamClass VertexDataPage::get_pending_ram_class | ( | ) | const [inline] |
Returns the pending ram class of the array.
If this is different from get_ram_class(), this page has been queued to be processed by the thread. Eventually the page will be set to this ram class.
Definition at line 38 of file vertexDataPage.I.
VertexDataPage::RamClass VertexDataPage::get_ram_class | ( | ) | const [inline] |
Returns the current ram class of the array.
If this is other than RC_resident, the array data is not resident in memory.
Definition at line 24 of file vertexDataPage.I.
VertexDataSaveFile * VertexDataPage::get_save_file | ( | ) | [inline, static] |
Returns the global VertexDataSaveFile that will be used to save vertex data buffers to disk when necessary.
Definition at line 128 of file vertexDataPage.I.
Referenced by GraphicsEngine::render_frame().
SimpleAllocatorBlock * VertexDataPage::make_block | ( | size_t | start, |
size_t | size | ||
) | [protected, virtual] |
Creates a new SimpleAllocatorBlock object.
Override this function to specialize the block type returned.
Reimplemented from SimpleAllocator.
Definition at line 250 of file vertexDataPage.cxx.
bool VertexDataPage::operator< | ( | const VertexDataPage & | other | ) | const [inline] |
This comparison method is used to order pages within a book.
Definition at line 235 of file vertexDataPage.I.
void VertexDataPage::request_resident | ( | ) | [inline] |
Ensures that the page will become resident soon.
Future calls to get_page_data() will eventually return non-NULL.
Definition at line 51 of file vertexDataPage.I.
bool VertexDataPage::save_to_disk | ( | ) | [inline] |
Writes the page to disk, but does not evict it from memory or affect its LRU status.
If it gets evicted later without having been modified, it will not need to write itself to disk again.
Definition at line 144 of file vertexDataPage.I.
void VertexDataPage::stop_threads | ( | ) | [static] |
Call this to stop the paging threads, if they were started.
This may block until all of the pending tasks have been completed.
Definition at line 181 of file vertexDataPage.cxx.
Referenced by flush_threads(), and GraphicsEngine::remove_all_windows().