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

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. More...

Inheritance diagram for VertexDataPage:
SimpleAllocator SimpleLruPage LinkedListNode LinkedListNode

Public Types

enum  RamClass { RC_resident = 0, RC_compressed = 1, RC_disk = 2, RC_end_of_list = 3 }
 These are used to indicate the current residency state of the page, which may or may not have been temporarily evicted to satisfy memory requirements. More...
 

Public Member Functions

VertexDataBlock alloc (size_t size)
 Allocates a new block. Returns NULL if a block of the requested size cannot be allocated. More...
 
VertexDataBook getBook ()
 Returns a pointer to the book that owns this page. More...
 
VertexDataBlock getFirstBlock ()
 Returns a pointer to the first allocated block, or NULL if there are no allocated blocks. More...
 
VertexDataPage::RamClass getPendingRamClass ()
 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. More...
 
VertexDataPage::RamClass getRamClass ()
 Returns the current ram class of the array. If this is other than RC_resident, the array data is not resident in memory. More...
 
 output (Ostream out)
 
 requestResident ()
 Ensures that the page will become resident soon. Future calls to get_page_data() will eventually return non-NULL. More...
 
bool saveToDisk ()
 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. More...
 
 write (Ostream out, int indent_level)
 
- Public Member Functions inherited from SimpleAllocator
 __init__ (size_t max_size, Mutex lock)
 
SimpleAllocatorBlock alloc (size_t size)
 Allocates a new block. Returns NULL if a block of the requested size cannot be allocated. More...
 
size_t getContiguous ()
 Returns an upper-bound estimate of the size of the largest contiguous block that may be allocated. It is guaranteed that an attempt to allocate a block larger than this will fail, though it is not guaranteed that an attempt to allocate a block this size or smaller will succeed. More...
 
SimpleAllocatorBlock getFirstBlock ()
 Returns a pointer to the first allocated block, or NULL if there are no allocated blocks. More...
 
size_t getMaxSize ()
 Returns the available space for allocated objects. More...
 
size_t getTotalSize ()
 Returns the total size of allocated objects. More...
 
bool isEmpty ()
 Returns true if there are no blocks allocated on this page, or false if there is at least one. More...
 
 output (Ostream out)
 
 setMaxSize (size_t max_size)
 Changes the available space for allocated objects. This will not affect any already-allocated objects, but will have an effect on future calls to alloc(). More...
 
 write (Ostream out)
 
- Public Member Functions inherited from SimpleLruPage
 __init__ (const SimpleLruPage copy)
 
 __init__ (size_t lru_size)
 
 dequeueLru ()
 Removes the page from its SimpleLru. More...
 
 enqueueLru (SimpleLru lru)
 Adds the page to the LRU for the first time, or marks it recently-accessed if it has already been added. More...
 
 evictLru ()
 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. More...
 
SimpleLru getLru ()
 Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU. More...
 
size_t getLruSize ()
 Returns the size of this page as reported to the LRU, presumably in bytes. More...
 
 markUsedLru ()
 To be called when the page is used; this will move it to the tail of the SimpleLru queue it is already on. More...
 
 markUsedLru (SimpleLru lru)
 To be called when the page is used; this will move it to the tail of the specified SimpleLru queue. More...
 
SimpleLruPage operator= (const SimpleLruPage copy)
 
 output (Ostream out)
 
 setLruSize (size_t lru_size)
 Specifies the size of this page, presumably in bytes, although any unit is possible. More...
 
 write (Ostream out, int indent_level)
 

Static Public Member Functions

static flushThreads ()
 Waits for all of the pending thread tasks to finish before returning. More...
 
static TypeHandle getClassType ()
 
static SimpleLru getGlobalLru (VertexDataPage::RamClass rclass)
 Returns a pointer to the global LRU object that manages the VertexDataPage's with the indicated RamClass. More...
 
static int getNumPendingReads ()
 Returns the number of read requests that are waiting to be serviced by a thread. More...
 
static int getNumPendingWrites ()
 Returns the number of write requests that are waiting to be serviced by a thread. More...
 
static int getNumThreads ()
 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 SimpleLru getPendingLru ()
 Returns a pointer to the global LRU object that manages the VertexDataPage's that are pending processing by the thread. More...
 
static VertexDataSaveFile getSaveFile ()
 Returns the global VertexDataSaveFile that will be used to save vertex data buffers to disk when necessary. More...
 
static stopThreads ()
 Call this to stop the paging threads, if they were started. This may block until all of the pending tasks have been completed. More...
 

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.

Member Enumeration Documentation

◆ RamClass

enum RamClass

These are used to indicate the current residency state of the page, which may or may not have been temporarily evicted to satisfy memory requirements.

Enumerator
RC_resident 
RC_compressed 
RC_disk 
RC_end_of_list 

list marker; do not use

Member Function Documentation

◆ alloc()

VertexDataBlock alloc ( size_t  size)

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.

◆ flushThreads()

static flushThreads ( )
static

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

◆ getBook()

VertexDataBook getBook ( )

Returns a pointer to the book that owns this page.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getFirstBlock()

VertexDataBlock getFirstBlock ( )

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

◆ getGlobalLru()

static SimpleLru getGlobalLru ( VertexDataPage::RamClass  rclass)
static

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

◆ getNumPendingReads()

static int getNumPendingReads ( )
static

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

◆ getNumPendingWrites()

static int getNumPendingWrites ( )
static

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

◆ getNumThreads()

static int getNumThreads ( )
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).

◆ getPendingLru()

static SimpleLru getPendingLru ( )
static

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

◆ getPendingRamClass()

VertexDataPage::RamClass getPendingRamClass ( )

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.

◆ getRamClass()

VertexDataPage::RamClass getRamClass ( )

Returns the current ram class of the array. If this is other than RC_resident, the array data is not resident in memory.

◆ getSaveFile()

static VertexDataSaveFile getSaveFile ( )
static

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

◆ output()

output ( Ostream  out)

◆ requestResident()

requestResident ( )

Ensures that the page will become resident soon. Future calls to get_page_data() will eventually return non-NULL.

◆ saveToDisk()

bool saveToDisk ( )

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.

◆ stopThreads()

static stopThreads ( )
static

Call this to stop the paging threads, if they were started. This may block until all of the pending tasks have been completed.

◆ write()

write ( Ostream  out,
int  indent_level 
)