Yate: RWLockPool Class Reference

Yate

Public Member Functions | List of all members
RWLockPool Class Reference

A RWLock pool. More...

`#include <yateclass.h>`

## Public Member Functions
| RWLockPool (unsigned int len=13, const char *name=0)
| ~RWLockPool ()
unsigned int | index (void *ptr) const
RWLock * | lock (void *ptr) const
RWLock * | lock (unsigned int idx) const

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ 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()

~RWLockPool | ( |  | ) |

Destructor. Release data

## Member Function Documentation

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

  ptr | The pointer to object

Returns
  Valid array index

Referenced by lock().

## ◆ lock() [1/2]

RWLock * lock | ( | unsigned int | idx | ) | const
| inline

Retrieve the lock at a given index modulo array length

Parameters

  idx | The index

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

  ptr | The pointer to object

Returns
  Valid RWLock pointer

References index().

The documentation for this class was generated from the following file:

- yateclass.h