Panda3D
Public Member Functions | Static Public Member Functions | List of all members
DeletedChain< Type > Class Template Reference

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

#include "deletedChain.h"

Public Member Functions

Type * allocate (size_t size, TypeHandle type_handle)
 
void deallocate (Type *ptr, TypeHandle type_handle)
 
bool validate (const Type *ptr)
 

Static Public Member Functions

static ReferenceCountmake_ref_ptr (void *ptr)
 
static ReferenceCountmake_ref_ptr (ReferenceCount *ptr)
 

Detailed Description

template<class Type>
class DeletedChain< Type >

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

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

This class is actually a layer on top of DeletedBufferChain, which handles the actual allocation. This class just provides the typecasting.

Of course, this trick of maintaining the deleted object chain won't work in the presence of polymorphism, where you might have many classes that derive from a base class, and all of them have a different size–unless you instantiate a DeletedChain for *every* kind of derived class. The ALLOC_DELETED_CHAIN macro, below, is designed to make this easy.

Definition at line 37 of file deletedChain.h.


The documentation for this class was generated from the following file: