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. | |
void | dequeue_lru () |
Removes the page from its SimpleLru. | |
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. | |
VertexDataBook * | get_book () const |
Returns a pointer to the book that owns this page. | |
size_t | get_contiguous () const |
Returns an upper-bound estimate of the size of the largest contiguous block that may be allocated. | |
VertexDataBlock * | get_first_block () const |
Returns a pointer to the first allocated block, or NULL if there are no allocated blocks. | |
SimpleLru * | get_lru () const |
Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU. | |
size_t | get_lru_size () const |
Returns the size of this page as reported to the LRU, presumably in bytes. | |
size_t | get_max_size () const |
Returns the available space for allocated objects. | |
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. | |
size_t | get_total_size () const |
Returns the total size of allocated objects. | |
bool | is_empty () const |
Returns true if there are no blocks allocated on this page, or false if there is at least one. | |
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. | |
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. | |
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. | |
void | set_lru_size (size_t lru_size) |
Specifies the size of this page, presumably in bytes, although any unit is possible. | |
void | set_max_size (size_t max_size) |
Changes the available space for allocated objects. | |
virtual void | write (ostream &out, int indent_level) const |
void | write (ostream &out) 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. | |
bool | do_is_empty () const |
Returns true if there are no blocks allocated on this page, or false if there is at least one. | |
virtual void | evict_lru () |
Evicts the page from the LRU. | |
void | insert_after (LinkedListNode *node) |
Adds a LinkedListNode record after the indicated node in the doubly-linked list. | |
void | insert_after (LinkedListNode *node) |
Adds a LinkedListNode record after the indicated node in the doubly-linked list. | |
void | insert_before (LinkedListNode *node) |
Adds a LinkedListNode record before the indicated node in the doubly-linked list. | |
void | insert_before (LinkedListNode *node) |
Adds a LinkedListNode record before the indicated node in the doubly-linked list. | |
bool | is_on_list () const |
Returns true if the node is member of any list, false if it has been removed or never added. | |
bool | is_on_list () const |
Returns true if the node is member of any list, false if it has been removed or never added. | |
virtual SimpleAllocatorBlock * | make_block (size_t start, size_t size) |
Creates a new SimpleAllocatorBlock object. | |
void | mark_contiguous (const LinkedListNode *block) |
Some space has been made available following the indicated block. | |
void | remove_from_list () |
Removes a LinkedListNode record from the doubly-linked list. | |
void | remove_from_list () |
Removes a LinkedListNode record from the doubly-linked list. | |
void | take_list_from (LinkedListNode *other_root) |
Given that this LinkedListNode represents the root of a list, and the other pointer represents the root of a different list, move all of the nodes (except the root itself) from other_root onto this list. | |
void | take_list_from (LinkedListNode *other_root) |
Given that this LinkedListNode represents the root of a list, and the other pointer represents the root of a different list, move all of the nodes (except the root itself) from other_root onto this list. | |
Protected Attributes | |
size_t | _contiguous |
Mutex & | _lock |
size_t | _max_size |
LinkedListNode * | _next |
LinkedListNode * | _next |
LinkedListNode * | _prev |
LinkedListNode * | _prev |
size_t | _total_size |
Friends | |
class | PageThread |
class | SimpleAllocatorBlock |
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 SimpleLruPage::dequeue_lru | ( | ) | [inline, inherited] |
Removes the page from its SimpleLru.
Definition at line 164 of file simpleLru.I.
References LinkedListNode::remove_from_list().
Referenced by SimpleLruPage::evict_lru(), and GeomVertexArrayData::evict_lru().
bool SimpleAllocator::do_is_empty | ( | ) | const [inline, protected, inherited] |
Returns true if there are no blocks allocated on this page, or false if there is at least one.
Assumes the lock is already held.
Definition at line 130 of file simpleAllocator.I.
Referenced by changed_contiguous(), and SimpleAllocator::is_empty().
void SimpleLruPage::enqueue_lru | ( | 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.
Definition at line 70 of file simpleLru.cxx.
References LinkedListNode::insert_before(), and LinkedListNode::remove_from_list().
Referenced by SimpleLru::begin_epoch(), and SimpleLruPage::mark_used_lru().
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.
size_t SimpleAllocator::get_contiguous | ( | ) | const [inline, 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.
Definition at line 104 of file simpleAllocator.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().
SimpleLru * SimpleLruPage::get_lru | ( | ) | const [inline, inherited] |
Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU.
Definition at line 153 of file simpleLru.I.
size_t SimpleLruPage::get_lru_size | ( | ) | const [inline, inherited] |
Returns the size of this page as reported to the LRU, presumably in bytes.
Definition at line 208 of file simpleLru.I.
size_t SimpleAllocator::get_max_size | ( | ) | const [inline, inherited] |
Returns the available space for allocated objects.
Definition at line 75 of file simpleAllocator.I.
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().
size_t SimpleAllocator::get_total_size | ( | ) | const [inline, inherited] |
Returns the total size of allocated objects.
Definition at line 64 of file simpleAllocator.I.
Referenced by VertexDataSaveFile::get_used_file_size().
void LinkedListNode::insert_after | ( | LinkedListNode * | node | ) | [inline, protected, inherited] |
Adds a LinkedListNode record after the indicated node in the doubly-linked list.
Definition at line 108 of file linkedListNode.I.
void LinkedListNode::insert_after | ( | LinkedListNode * | node | ) | [inline, protected, inherited] |
Adds a LinkedListNode record after the indicated node in the doubly-linked list.
Definition at line 108 of file linkedListNode.I.
void LinkedListNode::insert_before | ( | LinkedListNode * | node | ) | [inline, protected, inherited] |
Adds a LinkedListNode record before the indicated node in the doubly-linked list.
Definition at line 91 of file linkedListNode.I.
Referenced by SimpleAllocator::do_alloc(), AdaptiveLru::do_partial_lru_update(), and SimpleLruPage::enqueue_lru().
void LinkedListNode::insert_before | ( | LinkedListNode * | node | ) | [inline, protected, inherited] |
Adds a LinkedListNode record before the indicated node in the doubly-linked list.
Definition at line 91 of file linkedListNode.I.
Referenced by SimpleAllocator::do_alloc(), AdaptiveLru::do_partial_lru_update(), and SimpleLruPage::enqueue_lru().
bool SimpleAllocator::is_empty | ( | ) | const [inline, inherited] |
Returns true if there are no blocks allocated on this page, or false if there is at least one.
Definition at line 53 of file simpleAllocator.I.
References SimpleAllocator::do_is_empty().
bool LinkedListNode::is_on_list | ( | ) | const [inline, protected, inherited] |
Returns true if the node is member of any list, false if it has been removed or never added.
The head of a list generally appears to to always be a member of itself.
Definition at line 62 of file linkedListNode.I.
bool LinkedListNode::is_on_list | ( | ) | const [inline, protected, inherited] |
Returns true if the node is member of any list, false if it has been removed or never added.
The head of a list generally appears to to always be a member of itself.
Definition at line 62 of file linkedListNode.I.
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.
void SimpleAllocator::mark_contiguous | ( | const LinkedListNode * | block | ) | [inline, protected, inherited] |
Some space has been made available following the indicated block.
Increase the contiguous space accordingly.
Assumes the lock is already held.
Definition at line 144 of file simpleAllocator.I.
References SimpleAllocator::changed_contiguous().
Referenced by SimpleAllocatorBlock::do_free(), and SimpleAllocatorBlock::do_realloc().
void SimpleLruPage::mark_used_lru | ( | SimpleLru * | lru | ) | [inline, inherited] |
To be called when the page is used; this will move it to the tail of the specified SimpleLru queue.
Definition at line 197 of file simpleLru.I.
References SimpleLruPage::enqueue_lru().
void SimpleLruPage::mark_used_lru | ( | ) | const [inline, 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.
Definition at line 184 of file simpleLru.I.
Referenced by get_page_data(), and GeomVertexArrayData::operator=().
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 LinkedListNode::remove_from_list | ( | ) | [inline, protected, inherited] |
Removes a LinkedListNode record from the doubly-linked list.
Definition at line 73 of file linkedListNode.I.
Referenced by SimpleLruPage::dequeue_lru(), SimpleAllocatorBlock::do_free(), AdaptiveLru::do_partial_lru_update(), and SimpleLruPage::enqueue_lru().
void LinkedListNode::remove_from_list | ( | ) | [inline, protected, inherited] |
Removes a LinkedListNode record from the doubly-linked list.
Definition at line 73 of file linkedListNode.I.
Referenced by SimpleLruPage::dequeue_lru(), SimpleAllocatorBlock::do_free(), AdaptiveLru::do_partial_lru_update(), and SimpleLruPage::enqueue_lru().
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 SimpleLruPage::set_lru_size | ( | size_t | lru_size | ) | [inline, inherited] |
Specifies the size of this page, presumably in bytes, although any unit is possible.
Definition at line 219 of file simpleLru.I.
void SimpleAllocator::set_max_size | ( | size_t | max_size | ) | [inline, 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().
Definition at line 88 of file simpleAllocator.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().
void LinkedListNode::take_list_from | ( | LinkedListNode * | other_root | ) | [inline, protected, inherited] |
Given that this LinkedListNode represents the root of a list, and the other pointer represents the root of a different list, move all of the nodes (except the root itself) from other_root onto this list.
Definition at line 127 of file linkedListNode.I.
Referenced by BufferContextChain::take_from().
void LinkedListNode::take_list_from | ( | LinkedListNode * | other_root | ) | [inline, protected, inherited] |
Given that this LinkedListNode represents the root of a list, and the other pointer represents the root of a different list, move all of the nodes (except the root itself) from other_root onto this list.
Definition at line 127 of file linkedListNode.I.
Referenced by BufferContextChain::take_from().