# class MutexPool

A Mutex pool. More...

Full name | `TelEngine::MutexPool`
Definition | `#include <yateclass.h>`
List of all Methods

Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- MutexPool (unsigned int len = 13, bool recursive = false, const char* name = 0)
- ~MutexPool ()
- inline unsigned int index (void* ptr) const
- inline Mutex* mutex (void* ptr) const
- inline Mutex* mutex (unsigned int idx) const

## 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:

len | The 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
recursive | True if the mutex has to be recursive (reentrant), false for a normal fast mutex
name | Static 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:

ptr | The 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:

ptr | The 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:

idx | The index

Returns: Valid Mutex pointer

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