Mon Jun 27 16:51:23 2011

Asterisk developer's documentation


ao2_container Struct Reference


Data Fields

bucket buckets [0]
ao2_callback_fncmp_fn
int elements
ao2_hash_fnhash_fn
int n_buckets
int version

Detailed Description

A container; stores the hash and callback functions, information on the size, the hash bucket heads, and a version number, starting at 0 (for a newly created, empty container) and incremented every time an object is inserted or deleted. The assumption is that an object is never moved in a container, but removed and readded with the new number. The version number is especially useful when implementing iterators. In fact, we can associate a unique, monotonically increasing number to each object, which means that, within an iterator, we can store the version number of the current object, and easily look for the next one, which is the next one in the list with a higher number. Since all objects have a version >0, we can use 0 as a marker for 'we need the first object in the bucket'.

Todo:
Linking and unlink objects is typically expensive, as it involves a malloc() of a small object which is very inefficient. To optimize this, we allocate larger arrays of bucket_entry's when we run out of them, and then manage our own freelist. This will be more efficient as we can do the freelist management while we hold the lock (that we need anyways).

Definition at line 375 of file astobj2.c.


Field Documentation

struct bucket buckets[0]

variable size

Definition at line 384 of file astobj2.c.

Referenced by container_destruct(), container_destruct_debug(), internal_ao2_callback(), and internal_ao2_iterator_next().

ao2_callback_fn* cmp_fn

Definition at line 377 of file astobj2.c.

Referenced by __ao2_find(), __ao2_find_debug(), and internal_ao2_container_alloc().

int elements

Number of elements in the container

Definition at line 380 of file astobj2.c.

Referenced by ao2_container_count(), and internal_ao2_callback().

ao2_hash_fn* hash_fn

Definition at line 376 of file astobj2.c.

Referenced by internal_ao2_callback(), and internal_ao2_container_alloc().

int n_buckets

Definition at line 378 of file astobj2.c.

Referenced by container_destruct(), container_destruct_debug(), internal_ao2_callback(), internal_ao2_container_alloc(), and internal_ao2_iterator_next().

int version

described above

Definition at line 382 of file astobj2.c.

Referenced by internal_ao2_callback(), internal_ao2_container_alloc(), and internal_ao2_iterator_next().


The documentation for this struct was generated from the following file:
Generated on Mon Jun 27 16:51:23 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7