Panda3D
Classes | Public Member Functions | Protected Member Functions | Friends

DeletedBufferChain Class Reference

This template class can be used to provide faster allocation/deallocation for many Panda objects. More...

#include "deletedBufferChain.h"

List of all members.

Classes

class  ObjectNode

Public Member Functions

void * allocate (size_t size, TypeHandle type_handle)
 Allocates the memory for a new buffer of the indicated size (which must be no greater than the fixed size associated with the DeletedBufferChain).
void deallocate (void *ptr, TypeHandle type_handle)
 Frees the memory for a buffer previously allocated via allocate().
size_t get_buffer_size () const
 Returns the size of the buffer that is actually returned at each request.
bool validate (void *ptr)
 Returns true if the pointer is valid, false if it has been deleted or if it was never a valid pointer.

Protected Member Functions

 DeletedBufferChain (size_t buffer_size)
 Use the global MemoryHook to get a new DeletedBufferChain of the appropriate size.

Friends

class MemoryHook

Detailed Description

This template class can be used to provide faster allocation/deallocation for many Panda objects.

It works by maintaining a linked list of deleted buffers that are all of the same size; when a new object is allocated that matches that size, the same space is just reused.

This class manages untyped buffers of a fixed size. It can be used directly; or it also serves as a backbone for DeletedChain, which is a template class that manages object allocations.

Use MemoryHook to get a new DeletedBufferChain of a particular size.

Definition at line 65 of file deletedBufferChain.h.


Constructor & Destructor Documentation

DeletedBufferChain::DeletedBufferChain ( size_t  buffer_size) [protected]

Use the global MemoryHook to get a new DeletedBufferChain of the appropriate size.

Definition at line 25 of file deletedBufferChain.cxx.


Member Function Documentation

void * DeletedBufferChain::allocate ( size_t  size,
TypeHandle  type_handle 
)

Allocates the memory for a new buffer of the indicated size (which must be no greater than the fixed size associated with the DeletedBufferChain).

Definition at line 49 of file deletedBufferChain.cxx.

References NeverFreeMemory::alloc().

Referenced by RenderState::RenderState().

void DeletedBufferChain::deallocate ( void *  ptr,
TypeHandle  type_handle 
)

Frees the memory for a buffer previously allocated via allocate().

Definition at line 107 of file deletedBufferChain.cxx.

Referenced by RenderState::~RenderState().

size_t DeletedBufferChain::get_buffer_size ( ) const [inline]

Returns the size of the buffer that is actually returned at each request.

Definition at line 48 of file deletedBufferChain.I.

bool DeletedBufferChain::validate ( void *  ptr) [inline]

Returns true if the pointer is valid, false if it has been deleted or if it was never a valid pointer.

This is only meaningful in debug mode, where USE_DELETEDCHAINFLAG is defined. If not, this trivially returns true.

Definition at line 27 of file deletedBufferChain.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations