astobj2_private.h File Reference

Common, private definitions for astobj2. More...

#include "asterisk/astobj2.h"

Include dependency graph for astobj2_private.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define AO2_DEVMODE_STAT(stat)

Functions

enum ao2_lock_req __adjust_lock (void *user_data, enum ao2_lock_req lock_how, int keep_stronger)
int is_ao2_object (void *user_data)


Detailed Description

Common, private definitions for astobj2.

Author:
Richard Mudgett <rmudgett@digium.com>

Definition in file astobj2_private.h.


Define Documentation

#define AO2_DEVMODE_STAT ( stat   ) 


Function Documentation

enum ao2_lock_req __adjust_lock ( void *  user_data,
enum ao2_lock_req  lock_how,
int  keep_stronger 
)

Definition at line 336 of file astobj2.c.

References AO2_ALLOC_OPT_LOCK_MASK, AO2_ALLOC_OPT_LOCK_MUTEX, AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_ALLOC_OPT_LOCK_RWLOCK, AO2_LOCK_REQ_MUTEX, AO2_LOCK_REQ_RDLOCK, AO2_LOCK_REQ_WRLOCK, ao2_rdlock, ao2_unlock, ao2_wrlock, ast_log, INTERNAL_OBJ(), INTERNAL_OBJ_RWLOCK, LOG_ERROR, ao2_rwlock_priv::num_lockers, __priv_data::options, astobj2::priv_data, and astobj2_rwlock::rwlock.

Referenced by ao2_iterator_restart(), hash_ao2_node_destructor(), internal_ao2_iterator_next(), internal_ao2_link(), internal_ao2_traverse(), and rb_ao2_node_destructor().

00337 {
00338    struct astobj2 *obj = INTERNAL_OBJ(user_data);
00339    struct astobj2_rwlock *obj_rwlock;
00340    enum ao2_lock_req orig_lock;
00341 
00342    switch (obj->priv_data.options & AO2_ALLOC_OPT_LOCK_MASK) {
00343    case AO2_ALLOC_OPT_LOCK_RWLOCK:
00344       obj_rwlock = INTERNAL_OBJ_RWLOCK(user_data);
00345       if (obj_rwlock->rwlock.num_lockers < 0) {
00346          orig_lock = AO2_LOCK_REQ_WRLOCK;
00347       } else {
00348          orig_lock = AO2_LOCK_REQ_RDLOCK;
00349       }
00350       switch (lock_how) {
00351       case AO2_LOCK_REQ_MUTEX:
00352          lock_how = AO2_LOCK_REQ_WRLOCK;
00353          /* Fall through */
00354       case AO2_LOCK_REQ_WRLOCK:
00355          if (lock_how != orig_lock) {
00356             /* Switch from read lock to write lock. */
00357             ao2_unlock(user_data);
00358             ao2_wrlock(user_data);
00359          }
00360          break;
00361       case AO2_LOCK_REQ_RDLOCK:
00362          if (!keep_stronger && lock_how != orig_lock) {
00363             /* Switch from write lock to read lock. */
00364             ao2_unlock(user_data);
00365             ao2_rdlock(user_data);
00366          }
00367          break;
00368       }
00369       break;
00370    default:
00371       ast_log(LOG_ERROR, "Invalid lock option on ao2 object %p\n", user_data);
00372       /* Fall through */
00373    case AO2_ALLOC_OPT_LOCK_NOLOCK:
00374    case AO2_ALLOC_OPT_LOCK_MUTEX:
00375       orig_lock = AO2_LOCK_REQ_MUTEX;
00376       break;
00377    }
00378 
00379    return orig_lock;
00380 }

int is_ao2_object ( void *  user_data  ) 


Generated on Thu Apr 16 06:29:01 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6