@ -433,39 +433,51 @@ void *ao2_callback(ao2_container *c,
/*!
/*!
*
*
*
When we need to walk through a container , we use
* When we need to walk through a container , we use
ao2_iterator to keep track of the current position .
* ao2_iterator to keep track of the current position .
*
Because the navigation is typically done without holding the
* Because the navigation is typically done without holding the
lock on the container across the loop ,
* lock on the container across the loop ,
objects can be inserted or deleted or moved
* objects can be inserted or deleted or moved
while we work . As a consequence , there is no guarantee that
* while we work . As a consequence , there is no guarantee that
the we manage to touch all the elements on the list , or it
* the we manage to touch all the elements on the list , or it
is possible that we touch the same object multiple times .
* 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 ( ) ,
* - It is not possible to miss an object in the container while iterating
then we can use o = ao2_iterator_next ( ) to move from one
* unless it gets added after the iteration begins and is added to a bucket
element to the next . Remember that the object returned by
* that is before the one the current object is in . In this case , even if
ao2_iterator_next ( ) has its refcount incremented ,
* you locked the container around the entire iteration loop , you still would
and the reference must be explicitly released when done with it .
* not see this object , because it would still be waiting on the container
Example :
* lock so that it can be added .
* - It would be extremely rare to see an object twice . The only way this can
\ code
* happen is if an object got unlinked from the container and added again
* during the same iteration . Furthermore , when the object gets added back ,
ao2_container * c = . . . // the container we want to iterate on
* it has to be in the current or later bucket for it to be seen again .
ao2_iterator i ;
*
struct my_obj * o ;
* An iterator must be first initialized with ao2_iterator_init ( ) ,
* then we can use o = ao2_iterator_next ( ) to move from one
i = ao2_iterator_init ( c , flags ) ;
* element to the next . Remember that the object returned by
* ao2_iterator_next ( ) has its refcount incremented ,
while ( ( o = ao2_iterator_next ( & i ) ) ) {
* and the reference must be explicitly released when done with it .
. . . do something on o . . .
*
ao2_ref ( o , - 1 ) ;
* Example :
}
*
* \ code
\ endcode
*
* ao2_container * c = . . . // the container we want to iterate on
* 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 ) ;
* }
*
* \ endcode
*
*/
*/
/*!
/*!