BRL-CAD
ConstantPool< T > Class Template Reference

#include <constantpool.h>

Public Member Functions

 ConstantPool (size_t quanta=1000000)
 
 ~ConstantPool ()
 
T * alloc (size_t n)
 

Detailed Description

template<class T>
class OSL::pvt::ConstantPool< T >

A ConstantPool<T> is a way to allocate room for a small number of T's at a time, such that the memory allocated will NEVER change its address or be deallocated until the entire ConstantPool is destroyed. Allocating from the pool is completely thread-safe.

It is implemented as a linked list of memory blocks. A request for a new allocation tries to fit it in one of the allocated blocks, but if it won't fit anywhere, it makes a new block and adds it to the head of the list.

Definition at line 67 of file constantpool.h.

Constructor & Destructor Documentation

ConstantPool ( size_t  quanta = 1000000)
inline

Allocate a new pool of T's. The quanta, if supplied, is the number of T's to malloc at a time.

Definition at line 71 of file constantpool.h.

~ConstantPool ( )
inline

Definition at line 73 of file constantpool.h.

Member Function Documentation

T* alloc ( size_t  n)
inline

Allocate space enough for n T's, and return a pointer to the start of that space.

Definition at line 77 of file constantpool.h.


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