class MutexPool

A Mutex pool. More...

Full nameTelEngine::MutexPool
Definition#include <yateclass.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

This class holds a Mutex array. Mutexes can be retrieved based on object pointers. A mutex pool can be used to associate a smaller set of Mutex objects with a much larger set of objects needing lock.

 MutexPool (unsigned int len = 13, bool recursive = false, const char* name = 0)

MutexPool

Build the mutex pool

Parameters:
lenThe number of mutex objects to build. The length should be an odd number to obtain an optimal distribution of pointer based mutexes (usually pointers are aligned at even addresses): some mutexes might never get used if the length is an even number
recursiveTrue if the mutex has to be recursive (reentrant), false for a normal fast mutex
nameStatic name of the mutex (for debugging purpose only)

 ~MutexPool ()

~MutexPool

Destructor. Release data

inline unsigned int  index (void* ptr)

index

[const]

Build an index from object pointer (pointer value modulo array length). Always cast the pointer to the same type when calling this method to make sure the same index is returned for a given object

Parameters:
ptrThe pointer to object

Returns: Valid array index

inline Mutex*  mutex (void* ptr)

mutex

[const]

Retrieve the mutex associated with a given pointer. Always cast the pointer to the same type when calling this method to make sure the same mutex is returned for a given object

Parameters:
ptrThe pointer to object

Returns: Valid Mutex pointer

inline Mutex*  mutex (unsigned int idx)

mutex

[const]

Retrieve the mutex at a given index modulo array length

Parameters:
idxThe index

Returns: Valid Mutex pointer


Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54.