sipxportlib  Version 3.3
Protected Types | Protected Member Functions | Friends | List of all members
UtlChainPool Class Reference

Pool of available objects derived from UtlChain. More...

#include <UtlChainPool.h>

Protected Types

typedef void allocator(size_t blocksize, UtlChain *blockList, UtlChain *pool)
 Allocate blocksize instances of the subclass and chain them into the pool. More...
 

Protected Member Functions

 UtlChainPool (allocator *blockAllocator, size_t blockSize)
 Create a UtlChainPool that uses blockAllocator to create UtlChain derived objects. More...
 
UtlChainget ()
 Get a UtlLink with chain pointers NULL. More...
 
void release (UtlChain *freeChain)
 Return freeLink to the pool of available UtlLinks. More...
 
size_t totalAllocated ()
 Returns the total number of subclasses instances allocated by this pool. More...
 

Friends

class UtlLink
 
class UtlPair
 
class UtlInit
 

Detailed Description

Pool of available objects derived from UtlChain.

This avoids excessive heap operations; rather than delete unused UtlChains, they are stored on the mPool here. To limit the heap overhead associated with allocating UtlChain, they are allocated in mBlockSize blocks, which are chained on mBlocks.

The actual allocation of the blocks and initial chaining is done by the allocator function supplied by the UtlChain subclass.

Member Typedef Documentation

typedef void allocator(size_t blocksize,UtlChain *blockList,UtlChain *pool)
protected

Allocate blocksize instances of the subclass and chain them into the pool.

This function is supplied by the subclass to the UtlChainPool constructor. It is responsible for allocating a block of blocksize instances of its subclass. The first instance in each block is added to the blockList, so that the UtlChainPool destructor can delete the block. The remaining (blocksize-1) instances are chained onto the pool list header.

Constructor & Destructor Documentation

UtlChainPool ( allocator blockAllocator,
size_t  blockSize 
)
protected

Create a UtlChainPool that uses blockAllocator to create UtlChain derived objects.

Member Function Documentation

UtlChain * get ( )
protected

Get a UtlLink with chain pointers NULL.

void release ( UtlChain freeChain)
protected

Return freeLink to the pool of available UtlLinks.

size_t totalAllocated ( )
inlineprotected

Returns the total number of subclasses instances allocated by this pool.

The returned count does not include the 1 instance in each allocation that is consumed to manage the pool.

Friends And Related Function Documentation

friend class UtlLink
friend
friend class UtlPair
friend
friend class UtlInit
friend