Panda3D
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
VertexDataPage Class Reference

A block of bytes that holds one or more VertexDataBlocks. More...

#include "vertexDataPage.h"

Inheritance diagram for VertexDataPage:
SimpleAllocator SimpleLruPage LinkedListNode LinkedListNode

Public Types

enum  RamClass { RC_resident, RC_compressed, RC_disk, RC_end_of_list }
 

Public Member Functions

VertexDataBlockalloc (size_t size)
 Allocates a new block. More...
 
VertexDataBookget_book () const
 Returns a pointer to the book that owns this page. More...
 
VertexDataBlockget_first_block () const
 Returns a pointer to the first allocated block, or NULL if there are no allocated blocks. More...
 
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. More...
 
RamClass get_pending_ram_class () const
 Returns the pending ram class of the array. More...
 
RamClass get_ram_class () const
 Returns the current ram class of the array. More...
 
bool operator< (const VertexDataPage &other) const
 This comparison method is used to order pages within a book. More...
 
virtual void output (std::ostream &out) const
 
void request_resident ()
 Ensures that the page will become resident soon. More...
 
bool save_to_disk ()
 Writes the page to disk, but does not evict it from memory or affect its LRU status. More...
 
virtual void write (std::ostream &out, int indent_level) const
 
- Public Member Functions inherited from SimpleAllocator
 SimpleAllocator (size_t max_size, Mutex &lock)
 
 SimpleAllocator (SimpleAllocator &&from) noexcept
 Move constructor. More...
 
SimpleAllocatorBlockalloc (size_t size, size_t alignment=1)
 Allocates a new block. More...
 
size_t get_contiguous () const
 Returns an upper-bound estimate of the size of the largest contiguous block that may be allocated. More...
 
SimpleAllocatorBlockget_first_block () const
 Returns a pointer to the first allocated block, or NULL if there are no allocated blocks. More...
 
size_t get_max_size () const
 Returns the available space for allocated objects. More...
 
size_t get_total_size () const
 Returns the total size of allocated objects. More...
 
bool is_empty () const
 Returns true if there are no blocks allocated on this page, or false if there is at least one. More...
 
void output (std::ostream &out) const
 
void set_max_size (size_t max_size)
 Changes the available space for allocated objects. More...
 
void write (std::ostream &out) const
 
- Public Member Functions inherited from SimpleLruPage
 SimpleLruPage (size_t lru_size)
 
 SimpleLruPage (const SimpleLruPage &copy)
 
void dequeue_lru ()
 Removes the page from its SimpleLru. More...
 
void enqueue_lru (SimpleLru *lru)
 Adds the page to the LRU for the first time, or marks it recently-accessed if it has already been added. More...
 
SimpleLruget_lru () const
 Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU. More...
 
size_t get_lru_size () const
 Returns the size of this page as reported to the LRU, presumably in bytes. More...
 
void mark_used_lru () const
 To be called when the page is used; this will move it to the tail of the SimpleLru queue it is already on. More...
 
void mark_used_lru (SimpleLru *lru)
 To be called when the page is used; this will move it to the tail of the specified SimpleLru queue. More...
 
void operator= (const SimpleLruPage &copy)
 
void set_lru_size (size_t lru_size)
 Specifies the size of this page, presumably in bytes, although any unit is possible. More...
 

Static Public Member Functions

static void flush_threads ()
 Waits for all of the pending thread tasks to finish before returning. More...
 
static TypeHandle get_class_type ()
 
static SimpleLruget_global_lru (RamClass rclass)
 Returns a pointer to the global LRU object that manages the VertexDataPage's with the indicated RamClass. More...
 
static int get_num_pending_reads ()
 Returns the number of read requests that are waiting to be serviced by a thread. More...
 
static int get_num_pending_writes ()
 Returns the number of write requests that are waiting to be serviced by a thread. More...
 
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). More...
 
static SimpleLruget_pending_lru ()
 Returns a pointer to the global LRU object that manages the VertexDataPage's that are pending processing by the thread. More...
 
static VertexDataSaveFileget_save_file ()
 
static void init_type ()
 
static void stop_threads ()
 Call this to stop the paging threads, if they were started. More...
 

Public Attributes

 get_save_file
 Returns the global VertexDataSaveFile that will be used to save vertex data buffers to disk when necessary. More...
 

Friends

class PageThread
 
class VertexDataBook
 

Detailed Description

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 37 of file vertexDataPage.h.

Member Function Documentation

◆ alloc()

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.

Definition at line 55 of file vertexDataPage.I.

◆ flush_threads()

void VertexDataPage::flush_threads ( )
static

Waits for all of the pending thread tasks to finish before returning.

Definition at line 190 of file vertexDataPage.cxx.

◆ get_book()

VertexDataBook * VertexDataPage::get_book ( ) const
inline

Returns a pointer to the book that owns this page.

Definition at line 74 of file vertexDataPage.I.

◆ get_first_block()

VertexDataBlock * VertexDataPage::get_first_block ( ) const
inline

Returns a pointer to the first allocated block, or NULL if there are no allocated blocks.

Definition at line 65 of file vertexDataPage.I.

References SimpleAllocator::get_first_block().

◆ get_global_lru()

SimpleLru * VertexDataPage::get_global_lru ( RamClass  rclass)
inlinestatic

Returns a pointer to the global LRU object that manages the VertexDataPage's with the indicated RamClass.

Definition at line 83 of file vertexDataPage.I.

Referenced by GeomVertexArrayData::lru_epoch().

◆ get_num_pending_reads()

int VertexDataPage::get_num_pending_reads ( )
inlinestatic

Returns the number of read requests that are waiting to be serviced by a thread.

Definition at line 140 of file vertexDataPage.I.

◆ get_num_pending_writes()

int VertexDataPage::get_num_pending_writes ( )
inlinestatic

Returns the number of write requests that are waiting to be serviced by a thread.

Definition at line 153 of file vertexDataPage.I.

◆ get_num_threads()

int VertexDataPage::get_num_threads ( )
inlinestatic

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 127 of file vertexDataPage.I.

◆ get_page_data()

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 170 of file vertexDataPage.I.

References SimpleLruPage::mark_used_lru().

◆ get_pending_lru()

SimpleLru * VertexDataPage::get_pending_lru ( )
inlinestatic

Returns a pointer to the global LRU object that manages the VertexDataPage's that are pending processing by the thread.

Definition at line 93 of file vertexDataPage.I.

◆ get_pending_ram_class()

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 30 of file vertexDataPage.I.

◆ get_ram_class()

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 19 of file vertexDataPage.I.

◆ operator<()

bool VertexDataPage::operator< ( const VertexDataPage other) const
inline

This comparison method is used to order pages within a book.

Definition at line 192 of file vertexDataPage.I.

◆ request_resident()

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 40 of file vertexDataPage.I.

◆ save_to_disk()

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 115 of file vertexDataPage.I.

◆ stop_threads()

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 171 of file vertexDataPage.cxx.

Member Data Documentation

◆ get_save_file

VertexDataSaveFile * VertexDataPage::get_save_file
inline

Returns the global VertexDataSaveFile that will be used to save vertex data buffers to disk when necessary.

Definition at line 67 of file vertexDataPage.h.


The documentation for this class was generated from the following files: