Panda3D
Public Types | Public Member Functions | Static Public Member Functions

VertexDataPage Class Reference

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

Inheritance diagram for VertexDataPage:
SimpleAllocator SimpleLruPage LinkedListNode LinkedListNode

List of all members.

Public Types

enum  RamClass { RCResident = 0, RCCompressed = 1, RCDisk = 2, RCEndOfList = 3 }

Public Member Functions

VertexDataBlock alloc (unsigned int size)
 Allocates a new block.
 dequeueLru ()
 Removes the page from its SimpleLru.
 enqueueLru (SimpleLru lru)
 Adds the page to the LRU for the first time, or marks it recently-accessed if it has already been added.
 evictLru ()
 Evicts the page from the LRU.
VertexDataBook getBook ()
 Returns a pointer to the book that owns this page.
unsigned int getContiguous ()
 Returns an upper-bound estimate of the size of the largest contiguous block that may be allocated.
VertexDataBlock getFirstBlock ()
 Returns a pointer to the first allocated block, or NULL if there are no allocated blocks.
SimpleLru getLru ()
 Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU.
unsigned int getLruSize ()
 Returns the size of this page as reported to the LRU, presumably in bytes.
unsigned int getMaxSize ()
 Returns the available space for allocated objects.
RamClass getPendingRamClass ()
 Returns the pending ram class of the array.
RamClass getRamClass ()
 Returns the current ram class of the array.
unsigned int getTotalSize ()
 Returns the total size of allocated objects.
bool isEmpty ()
 Returns true if there are no blocks allocated on this page, or false if there is at least one.
 markUsedLru ()
 To be called when the page is used; this will move it to the tail of the SimpleLru queue it is already on.
 markUsedLru (SimpleLru lru)
 To be called when the page is used; this will move it to the tail of the specified SimpleLru queue.
 output (ostream out)
 requestResident ()
 Ensures that the page will become resident soon.
bool saveToDisk ()
 Writes the page to disk, but does not evict it from memory or affect its LRU status.
 setLruSize (unsigned int lru_size)
 Specifies the size of this page, presumably in bytes, although any unit is possible.
 setMaxSize (unsigned int max_size)
 Changes the available space for allocated objects.
 write (ostream out, int indent_level)
 write (ostream out)

Static Public Member Functions

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

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

enum RamClass
Enumerator:
RCResident 
RCCompressed 
RCDisk 
RCEndOfList 

Member Function Documentation

VertexDataBlock alloc ( unsigned int  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.

Reimplemented from SimpleAllocator.

dequeueLru ( ) [inherited]

Removes the page from its SimpleLru.

enqueueLru ( SimpleLru  lru) [inherited]

Adds the page to the LRU for the first time, or marks it recently-accessed if it has already been added.

If lru is NULL, it means to remove this page from its LRU.

evictLru ( ) [inherited]

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

static flushThreads ( ) [static]

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

VertexDataBook getBook ( )

Returns a pointer to the book that owns this page.

static TypeHandle getClassType ( ) [static]
unsigned int getContiguous ( ) [inherited]

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.

VertexDataBlock getFirstBlock ( )

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

Reimplemented from SimpleAllocator.

static SimpleLru getGlobalLru ( RamClass  rclass) [static]

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

SimpleLru getLru ( ) [inherited]

Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU.

unsigned int getLruSize ( ) [inherited]

Returns the size of this page as reported to the LRU, presumably in bytes.

unsigned int getMaxSize ( ) [inherited]

Returns the available space for allocated objects.

static int getNumPendingReads ( ) [static]

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

static int getNumPendingWrites ( ) [static]

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

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

static SimpleLru getPendingLru ( ) [static]

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

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.

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.

static VertexDataSaveFile getSaveFile ( ) [static]

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

unsigned int getTotalSize ( ) [inherited]

Returns the total size of allocated objects.

bool isEmpty ( ) [inherited]

Returns true if there are no blocks allocated on this page, or false if there is at least one.

markUsedLru ( SimpleLru  lru) [inherited]

To be called when the page is used; this will move it to the tail of the specified SimpleLru queue.

markUsedLru ( ) [inherited]

To be called when the page is used; this will move it to the tail of the SimpleLru queue it is already on.

This method is const because it's not technically modifying the contents of the page itself.

output ( ostream  out)

Reimplemented from SimpleLruPage.

requestResident ( )

Ensures that the page will become resident soon.

Future calls to get_page_data() will eventually return non-NULL.

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.

setLruSize ( unsigned int  lru_size) [inherited]

Specifies the size of this page, presumably in bytes, although any unit is possible.

setMaxSize ( unsigned int  max_size) [inherited]

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().

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 ( ostream  out,
int  indent_level 
)

Reimplemented from SimpleLruPage.

write ( ostream  out) [inherited]
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties