When we need to walk through a container, we use ao2_iterator to keep track of the current position. More...
#include <astobj2.h>

Data Fields | |
| int | bucket |
| struct ao2_container * | c |
| unsigned int | c_version |
| int | flags |
| void * | obj |
| unsigned int | version |
When we need to walk through a container, we use ao2_iterator to keep track of the current position.
Because the navigation is typically done without holding the lock on the container across the loop, objects can be inserted or deleted or moved while we work. As a consequence, there is no guarantee that the we manage to touch all the elements on the list, or it is possible that we touch the same object multiple times. However, within the current hash table container, the following is true:
An iterator must be first initialized with ao2_iterator_init(), then we can use o = ao2_iterator_next() to move from one element to the next. Remember that the object returned by ao2_iterator_next() has its refcount incremented, and the reference must be explicitly released when done with it.
Example:
struct ao2_container *c = ... // the container we want to iterate on struct ao2_iterator i; struct my_obj *o; i = ao2_iterator_init(c, flags); while ( (o = ao2_iterator_next(&i)) ) { ... do something on o ... ao2_ref(o, -1); }
The Astobj2 iterator
Details are in the implementation of ao2_iterator_next() A freshly-initialized iterator has bucket=0, version = 0.
Definition at line 999 of file astobj2.h.
| int bucket |
struct ao2_container* c [read] |
the container
Definition at line 1001 of file astobj2.h.
Referenced by __ao2_iterator_next(), _ao2_iterator_next(), _ao2_iterator_next_debug(), and ao2_iterator_init().
| unsigned int c_version |
| int flags |
operation flags
Definition at line 1003 of file astobj2.h.
Referenced by __ao2_iterator_next(), _ao2_iterator_next(), _ao2_iterator_next_debug(), and ao2_iterator_init().
| void* obj |
pointer to the current object
Definition at line 1010 of file astobj2.h.
Referenced by __ao2_iterator_next().
| unsigned int version |
container version when the object was created
Definition at line 1012 of file astobj2.h.
Referenced by __ao2_iterator_next().
1.6.1