A RWLock pool.
More...
#include <yateclass.h>
A RWLock pool.
This class holds a RWLock array. Locks can be retrieved based on object pointers. A lock pool can be used to associate a smaller set of RWLock objects with a much larger set of objects needing lock.
◆ RWLockPool()
RWLockPool |
( |
unsigned int | len = 13, |
|
|
const char * | name = 0 ) |
Build the lock pool
- Parameters
-
len | The number of lock objects to build. The length should be an odd number to obtain an optimal distribution of pointer based locks (usually pointers are aligned at even addresses): some locks might never get used if the length is an even number |
name | Static name of the lock (for debugging purpose only) |
◆ ~RWLockPool()
◆ index()
unsigned int index |
( |
void * | ptr | ) |
const |
|
inline |
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
-
- Returns
- Valid array index
◆ lock() [1/2]
RWLock * lock |
( |
unsigned int | idx | ) |
const |
|
inline |
Retrieve the lock at a given index modulo array length
- Parameters
-
- Returns
- Valid RWLock pointer
◆ lock() [2/2]
RWLock * lock |
( |
void * | ptr | ) |
const |
|
inline |
Retrieve the lock associated with a given pointer. Always cast the pointer to the same type when calling this method to make sure the same lock is returned for a given object
- Parameters
-
- Returns
- Valid RWLock pointer
The documentation for this class was generated from the following file: