sipxmedialib  Version 3.3
Protected Member Functions | Protected Attributes | Private Attributes | List of all members
MpBufPool Class Reference

Pool of buffers. More...

#include <MpBufPool.h>

Collaboration diagram for MpBufPool:
Collaboration graph
[legend]

Public Member Functions

Creators
 MpBufPool (unsigned blockSize, unsigned numBlocks, const UtlString &poolName)
 Creates pool with numBlocks in it. Each block have size blockSize. More...
 
virtual ~MpBufPool ()
 Destroys pool. More...
 
Manipulators
MpBufgetBuffer ()
 Get free block from pool. More...
 
void releaseBuffer (MpBuf *pBuffer)
 Bring this buffer back to pool. More...
 
Accessors
unsigned getBlockSize () const
 Return size of the one block in the pool (in bytes). More...
 
unsigned getNumBlocks () const
 Return number of blocks in the pool. More...
 
int getBufferNumber (MpBuf *pBuf) const
 Return number of the buffer in the pool. Use this for debug output. More...
 
int getFreeBufferCount ()
 Return the number of free buffers. More...
 
int scanBufPool (MpFlowGraphBase *pFG)
 Scan for orphan buffers. More...
 
int profileFlowgraphPoolUsage ()
 Syslog a histigram of buffers used by flowgraph. More...
 
const UtlString & getName ()
 Get the name label for this pool. More...
 

Protected Member Functions

void * getPoolDataEnd ()
 Return pointer to the byte after end of the pool data. More...
 
char * getNextBlock (char *pBlock)
 Return pointer to the block, next to this. More...
 
void appendFreeList (MpBuf *pBuf)
 

Protected Attributes

UtlString mPoolName
 label or name for debug More...
 
unsigned mBlockSize
 Requested size of each block in pool (in bytes). More...
 
unsigned mBlockSpan
 Actual size of each block. >= mBlockSize for alignment. More...
 
unsigned mNumBlocks
 Number of blocks in pool. More...
 
unsigned mPoolBytes
 Size of all pool in bytes. More...
 
char * mpPoolData
 
MpBufListmpFreeList
 
OsMutex mMutex
 Mutex to avoid concurrent access to the pool. More...
 

Private Attributes

unsigned mNumGets
 
unsigned mNumFrees
 For statistics. More...
 
unsigned mNumFree
 For statistics. More...
 
unsigned mMinFree
 For statistics. More...
 

Detailed Description

Pool of buffers.

Constructor & Destructor Documentation

MpBufPool ( unsigned  blockSize,
unsigned  numBlocks,
const UtlString &  poolName 
)

Creates pool with numBlocks in it. Each block have size blockSize.

~MpBufPool ( )
virtual

Destroys pool.

Member Function Documentation

MpBuf * getBuffer ( )

Get free block from pool.

Returns
If there are no free blocks in pool invalid pointer returned.
void releaseBuffer ( MpBuf pBuffer)

Bring this buffer back to pool.

unsigned getBlockSize ( ) const
inline

Return size of the one block in the pool (in bytes).

unsigned getNumBlocks ( ) const
inline

Return number of blocks in the pool.

int getBufferNumber ( MpBuf pBuf) const

Return number of the buffer in the pool. Use this for debug output.

int getFreeBufferCount ( )

Return the number of free buffers.

int scanBufPool ( MpFlowGraphBase pFG)

Scan for orphan buffers.

int profileFlowgraphPoolUsage ( )

Syslog a histigram of buffers used by flowgraph.

const UtlString & getName ( )

Get the name label for this pool.

void* getPoolDataEnd ( )
inlineprotected

Return pointer to the byte after end of the pool data.

char* getNextBlock ( char *  pBlock)
inlineprotected

Return pointer to the block, next to this.

void appendFreeList ( MpBuf pBuf)
protected

Member Data Documentation

UtlString mPoolName
protected

label or name for debug

unsigned mBlockSize
protected

Requested size of each block in pool (in bytes).

unsigned mBlockSpan
protected

Actual size of each block. >= mBlockSize for alignment.

unsigned mNumBlocks
protected

Number of blocks in pool.

unsigned mPoolBytes
protected

Size of all pool in bytes.

char* mpPoolData
protected

Pointer to allocated memory. May be padded to match align rules.

MpBufList* mpFreeList
protected

Begin of the free blocks list. NULL if there are no free blocks availiable.

OsMutex mMutex
protected

Mutex to avoid concurrent access to the pool.

unsigned mNumGets
private
unsigned mNumFrees
private

For statistics.

unsigned mNumFree
private

For statistics.

unsigned mMinFree
private

For statistics.