Panda3D
|
A temporary file to hold the vertex data that has been evicted from memory and written to disk. More...
#include "vertexDataSaveFile.h"
Public Member Functions | |
VertexDataSaveFile (const Filename &directory, const string &prefix, size_t max_size) | |
SimpleAllocatorBlock * | alloc (size_t size) |
Allocates a new block. | |
size_t | get_contiguous () const |
Returns an upper-bound estimate of the size of the largest contiguous block that may be allocated. | |
SimpleAllocatorBlock * | get_first_block () const |
Returns a pointer to the first allocated block, or NULL if there are no allocated blocks. | |
size_t | get_max_size () const |
Returns the available space for allocated objects. | |
size_t | get_total_file_size () const |
Returns the amount of space consumed by the save file, including unused portions. | |
size_t | get_total_size () const |
Returns the total size of allocated objects. | |
size_t | get_used_file_size () const |
Returns the amount of space within the save file that is currently in use. | |
bool | is_empty () const |
Returns true if there are no blocks allocated on this page, or false if there is at least one. | |
bool | is_valid () const |
Returns true if the save file was successfully created and is ready for use, false if there was an error. | |
void | output (ostream &out) const |
PT (VertexDataSaveBlock) write_data(const unsigned char *data | |
bool | read_data (unsigned char *data, size_t size, VertexDataSaveBlock *block) |
Reads a block of data from the file, and returns true on success, false on failure. | |
void | set_max_size (size_t max_size) |
Changes the available space for allocated objects. | |
void | write (ostream &out) const |
Public Attributes | |
size_t bool | compressed |
size_t | size |
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. | |
SimpleAllocatorBlock * | do_alloc (size_t size) |
Allocates a new block. | |
bool | do_is_empty () const |
Returns true if there are no blocks allocated on this page, or false if there is at least one. | |
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. | |
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 | 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 |
size_t | _max_size |
LinkedListNode * | _next |
LinkedListNode * | _prev |
size_t | _total_size |
Friends | |
class | SimpleAllocatorBlock |
A temporary file to hold the vertex data that has been evicted from memory and written to disk.
All vertex data arrays are written into one large flat file.
Definition at line 37 of file vertexDataSaveFile.h.
SimpleAllocatorBlock * SimpleAllocator::alloc | ( | size_t | size | ) | [inline, inherited] |
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 in VertexDataPage.
Definition at line 41 of file simpleAllocator.I.
References SimpleAllocator::do_alloc().
void SimpleAllocator::changed_contiguous | ( | ) | [protected, virtual, inherited] |
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 in VertexDataPage.
Definition at line 177 of file simpleAllocator.cxx.
Referenced by SimpleAllocator::do_alloc(), and SimpleAllocator::mark_contiguous().
SimpleAllocatorBlock * SimpleAllocator::do_alloc | ( | size_t | size | ) | [protected, inherited] |
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.
Assumes the lock is already held.
Definition at line 78 of file simpleAllocator.cxx.
References SimpleAllocator::changed_contiguous(), SimpleAllocatorBlock::get_allocator(), LinkedListNode::insert_before(), and SimpleAllocator::make_block().
Referenced by SimpleAllocator::alloc().
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 VertexDataPage::changed_contiguous(), and SimpleAllocator::is_empty().
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.
SimpleAllocatorBlock * SimpleAllocator::get_first_block | ( | ) | const [inline, inherited] |
Returns a pointer to the first allocated block, or NULL if there are no allocated blocks.
Reimplemented in VertexDataPage.
Definition at line 116 of file simpleAllocator.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.
size_t VertexDataSaveFile::get_total_file_size | ( | ) | const [inline] |
Returns the amount of space consumed by the save file, including unused portions.
Definition at line 35 of file vertexDataSaveFile.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 get_used_file_size().
size_t VertexDataSaveFile::get_used_file_size | ( | ) | const [inline] |
Returns the amount of space within the save file that is currently in use.
Definition at line 46 of file vertexDataSaveFile.I.
References SimpleAllocator::get_total_size().
Referenced by GraphicsEngine::render_frame().
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().
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 VertexDataSaveFile::is_valid | ( | ) | const [inline] |
Returns true if the save file was successfully created and is ready for use, false if there was an error.
Definition at line 24 of file vertexDataSaveFile.I.
SimpleAllocatorBlock * VertexDataSaveFile::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 356 of file vertexDataSaveFile.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().
bool VertexDataSaveFile::read_data | ( | unsigned char * | data, |
size_t | size, | ||
VertexDataSaveBlock * | block | ||
) |
Reads a block of data from the file, and returns true on success, false on failure.
Definition at line 274 of file vertexDataSaveFile.cxx.
References Thread::consider_yield(), Thread::force_yield(), Thread::get_current_thread(), ClockObject::get_global_clock(), ClockObject::get_real_time(), SimpleAllocatorBlock::get_size(), and SimpleAllocatorBlock::get_start().
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 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 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().