A set of macros implementing objects and containers. Macros are used for maximum performance, to support multiple inheritance, and to be easily integrated into existing structures without additional malloc calls, etc. More...
#include "asterisk/lock.h"
Go to the source code of this file.
Defines | |
#define | __ASTOBJ_HASH(type, hashes) type *next[1] |
#define | ASTOBJ_COMPONENTS(type) |
Add ASTOBJ components to a struct (with locking support). | |
#define | ASTOBJ_COMPONENTS_FULL(type, namelen, hashes) |
Add ASTOBJ components to a struct (with locking support). | |
#define | ASTOBJ_COMPONENTS_NOLOCK(type) ASTOBJ_COMPONENTS_NOLOCK_FULL(type,ASTOBJ_DEFAULT_NAMELEN,1) |
Add ASTOBJ components to a struct (without locking support). | |
#define | ASTOBJ_COMPONENTS_NOLOCK_FULL(type, namelen, hashes) |
Add ASTOBJ components to a struct (without locking support). | |
#define | ASTOBJ_CONTAINER_COMPONENTS(type) |
Create a container for ASTOBJs (with locking support). | |
#define | ASTOBJ_CONTAINER_COMPONENTS_NOLOCK(type) ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(type,1,ASTOBJ_DEFAULT_BUCKETS) |
Create a container for ASTOBJs (without locking support). | |
#define | ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(type, hashes, buckets) type *head |
Create a container for ASTOBJs (without locking support). | |
#define | ASTOBJ_CONTAINER_DESTROY(container) ASTOBJ_CONTAINER_DESTROY_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS) |
Destroy a container. | |
#define | ASTOBJ_CONTAINER_DESTROY_FULL(container, hashes, buckets) |
Destroy a container. | |
#define | ASTOBJ_CONTAINER_DESTROYALL(container, destructor) |
Empty a container. | |
#define | ASTOBJ_CONTAINER_DUMP(fd, s, slen, container) ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, "%s", s); } while(0)) |
Dump information about all the objects in a container to a file descriptor. | |
#define | ASTOBJ_CONTAINER_FIND(container, namestr) |
Find an object in a container. | |
#define | ASTOBJ_CONTAINER_FIND_FULL(container, data, field, hashfunc, hashoffset, comparefunc) |
Find an object in a container. | |
#define | ASTOBJ_CONTAINER_FIND_UNLINK(container, namestr) |
Find and remove an object from a container. | |
#define | ASTOBJ_CONTAINER_FIND_UNLINK_FULL(container, data, field, hashfunc, hashoffset, comparefunc) |
Find and remove an object in a container. | |
#define | ASTOBJ_CONTAINER_INIT(container) ASTOBJ_CONTAINER_INIT_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS) |
Initialize a container. | |
#define | ASTOBJ_CONTAINER_INIT_FULL(container, hashes, buckets) |
Initialize a container. | |
#define | ASTOBJ_CONTAINER_LINK(container, newobj) ASTOBJ_CONTAINER_LINK_FULL(container,newobj,(newobj)->name,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp) |
Add an object to a container. | |
#define | ASTOBJ_CONTAINER_LINK_END(container, newobj) |
Add an object to the end of a container. | |
#define | ASTOBJ_CONTAINER_LINK_FULL(container, newobj, data, field, hashfunc, hashoffset, comparefunc) |
Add an object to a container. | |
#define | ASTOBJ_CONTAINER_LINK_START(container, newobj) |
Add an object to the front of a container. | |
#define | ASTOBJ_CONTAINER_MARKALL(container) ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_MARK(iterator)) |
Mark all the objects in a container. | |
#define | ASTOBJ_CONTAINER_PRUNE_MARKED(container, destructor) |
Prune marked objects from a container. | |
#define | ASTOBJ_CONTAINER_RDLOCK(container) ast_mutex_lock(&(container)->_lock) |
Lock an ASTOBJ_CONTAINER for reading. | |
#define | ASTOBJ_CONTAINER_TRAVERSE(container, continue, eval) |
Iterate through the objects in a container. | |
#define | ASTOBJ_CONTAINER_UNLINK(container, obj) |
Remove an object from a container. | |
#define | ASTOBJ_CONTAINER_UNLINK_START(container) |
Remove an object from the front of a container. | |
#define | ASTOBJ_CONTAINER_UNLOCK(container) ast_mutex_unlock(&(container)->_lock) |
Unlock an ASTOBJ_CONTAINER. | |
#define | ASTOBJ_CONTAINER_UNMARKALL(container) ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_UNMARK(iterator)) |
Unmark all the objects in a container. | |
#define | ASTOBJ_CONTAINER_WRLOCK(container) ast_mutex_lock(&(container)->_lock) |
Lock an ASTOBJ_CONTAINER for writing. | |
#define | ASTOBJ_DEFAULT_BUCKETS 256 |
#define | ASTOBJ_DEFAULT_HASH ast_strhash |
#define | ASTOBJ_DEFAULT_NAMELEN 80 |
#define | ASTOBJ_DUMP(s, slen, obj) snprintf((s),(slen),"name: %s\nobjflags: %u\nrefcount: %u\n\n", (obj)->name, (obj)->objflags, (obj)->refcount); |
Dump information about an object into a string. | |
#define | ASTOBJ_FLAG_MARKED (1 << 0) |
#define | ASTOBJ_INIT(object) |
Initialize an object. | |
#define | ASTOBJ_MARK(object) |
Mark an ASTOBJ by adding the ASTOBJ_FLAG_MARKED flag to its objflags mask. | |
#define | ASTOBJ_RDLOCK(object) ast_mutex_lock(&(object)->_lock) |
Lock an ASTOBJ for reading. | |
#define | ASTOBJ_REF(object) |
Increment an object reference count. | |
#define | ASTOBJ_TRYWRLOCK(object) ast_mutex_trylock(&(object)->_lock) |
#define | ASTOBJ_UNLOCK(object) ast_mutex_unlock(&(object)->_lock) |
Unlock a locked object. | |
#define | ASTOBJ_UNMARK(object) |
Unmark an ASTOBJ by subtracting the ASTOBJ_FLAG_MARKED flag from its objflags mask. | |
#define | ASTOBJ_UNREF(object, destructor) |
Decrement the reference count on an object. | |
#define | ASTOBJ_WRLOCK(object) ast_mutex_lock(&(object)->_lock) |
Lock an ASTOBJ for writing. |
A set of macros implementing objects and containers. Macros are used for maximum performance, to support multiple inheritance, and to be easily integrated into existing structures without additional malloc calls, etc.
These macros expect to operate on two different object types, ASTOBJs and ASTOBJ_CONTAINERs. These are not actual types, as any struct can be converted into an ASTOBJ compatible object or container using the supplied macros.
Sample Usage:
struct sample_object { ASTOBJ_COMPONENTS(struct sample_object); }; struct sample_container { ASTOBJ_CONTAINER_COMPONENTS(struct sample_object); } super_container; void sample_object_destroy(struct sample_object *obj) { free(obj); } int init_stuff() { struct sample_object *obj1; struct sample_object *found_obj; obj1 = malloc(sizeof(struct sample_object)); ASTOBJ_CONTAINER_INIT(&super_container); ASTOBJ_INIT(obj1); ASTOBJ_WRLOCK(obj1); ast_copy_string(obj1->name, "obj1", sizeof(obj1->name)); ASTOBJ_UNLOCK(obj1); ASTOBJ_CONTAINER_LINK(&super_container, obj1); found_obj = ASTOBJ_CONTAINER_FIND(&super_container, "obj1"); if(found_obj) { printf("Found object: %s", found_obj->name); ASTOBJ_UNREF(found_obj,sample_object_destroy); } ASTOBJ_CONTAINER_DESTROYALL(&super_container,sample_object_destroy); ASTOBJ_CONTAINER_DESTROY(&super_container); return 0; }
Definition in file astobj.h.
#define ASTOBJ_COMPONENTS | ( | type | ) |
ASTOBJ_COMPONENTS_NOLOCK(type); \ ast_mutex_t _lock;
Add ASTOBJ components to a struct (with locking support).
type | The datatype of the object. |
This macro works like ASTOBJ_COMPONENTS_NOLOCK() except it includes locking support.
Sample Usage:
struct sample_struct { ASTOBJ_COMPONENTS(struct sample_struct); };
#define ASTOBJ_COMPONENTS_FULL | ( | type, | |||
namelen, | |||||
hashes | ) |
ASTOBJ_COMPONENTS_NOLOCK_FULL(type,namelen,hashes); \ ast_mutex_t _lock;
Add ASTOBJ components to a struct (with locking support).
type | The datatype of the object. | |
namelen | The length to make the name char array. | |
hashes | The number of containers the object can be present in. |
This macro adds components to a struct to make it an ASTOBJ and includes support for locking.
Sample Usage:
struct sample_struct { ASTOBJ_COMPONENTS_FULL(struct sample_struct,1,1); };
#define ASTOBJ_COMPONENTS_NOLOCK | ( | type | ) | ASTOBJ_COMPONENTS_NOLOCK_FULL(type,ASTOBJ_DEFAULT_NAMELEN,1) |
Add ASTOBJ components to a struct (without locking support).
type | The datatype of the object. |
This macro works like ASTOBJ_COMPONENTS_NOLOCK_FULL() except it only accepts a type and uses default values for namelen and hashes.
Sample Usage:
struct sample_struct_componets { ASTOBJ_COMPONENTS_NOLOCK(struct sample_struct); };
#define ASTOBJ_COMPONENTS_NOLOCK_FULL | ( | type, | |||
namelen, | |||||
hashes | ) |
char name[namelen]; \ unsigned int refcount; \ unsigned int objflags; \ __ASTOBJ_HASH(type,hashes)
Add ASTOBJ components to a struct (without locking support).
type | The datatype of the object. | |
namelen | The length to make the name char array. | |
hashes | The number of containers the object can be present in. |
This macro adds components to a struct to make it an ASTOBJ. This macro differs from ASTOBJ_COMPONENTS_FULL in that it does not create a mutex for locking.
Sample Usage:
struct sample_struct { ASTOBJ_COMPONENTS_NOLOCK_FULL(struct sample_struct,1,1); };
#define ASTOBJ_CONTAINER_COMPONENTS | ( | type | ) |
Create a container for ASTOBJs (with locking support).
type | The type of objects the container will hold. |
This macro is used to create a container for ASTOBJs with locking support.
Sample Usage:
struct sample_struct_container { ASTOBJ_CONTAINER_COMPONENTS(struct sample_struct); };
#define ASTOBJ_CONTAINER_COMPONENTS_NOLOCK | ( | type | ) | ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(type,1,ASTOBJ_DEFAULT_BUCKETS) |
Create a container for ASTOBJs (without locking support).
type | The type of objects the container will hold. |
This macro is used to create a container for ASTOBJs without locking support.
Sample Usage:
struct sample_struct_nolock_container { ASTOBJ_CONTAINER_COMPONENTS_NOLOCK(struct sample_struct); };
#define ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL | ( | type, | |||
hashes, | |||||
buckets | ) | type *head |
Create a container for ASTOBJs (without locking support).
type | The type of objects the container will hold. | |
hashes | Currently unused. | |
buckets | Currently unused. |
This macro is used to create a container for ASTOBJs without locking support.
Sample Usage:
struct sample_struct_nolock_container { ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(struct sample_struct,1,1); };
#define ASTOBJ_CONTAINER_DESTROY | ( | container | ) | ASTOBJ_CONTAINER_DESTROY_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS) |
Destroy a container.
container | A pointer to the container to destory. |
This macro frees up resources used by a container. It does not operate on the objects in the container. To unlink the objects from the container use ASTOBJ_CONTAINER_DESTROYALL().
Definition at line 765 of file astobj.h.
Referenced by _unload_module(), ast_aji_client_destroy(), ast_netsock_release(), ast_smdi_interface_destroy(), load_module(), and unload_module().
#define ASTOBJ_CONTAINER_DESTROY_FULL | ( | container, | |||
hashes, | |||||
buckets | ) |
do { \ ast_mutex_destroy(&(container)->_lock); \ } while(0)
Destroy a container.
container | A pointer to the container to destroy. | |
hashes | Currently unused. | |
buckets | Currently unused. |
This macro frees up resources used by a container. It does not operate on the objects in the container. To unlink the objects from the container use ASTOBJ_CONTAINER_DESTROYALL().
#define ASTOBJ_CONTAINER_DESTROYALL | ( | container, | |||
destructor | ) |
Empty a container.
container | A pointer to the container to operate on. | |
destructor | A destructor function to call on each object. |
This macro loops through a container removing all the items from it using ASTOBJ_UNREF(). This does not destroy the container itself, use ASTOBJ_CONTAINER_DESTROY() for that.
Definition at line 453 of file astobj.h.
Referenced by _unload_module(), ast_aji_client_destroy(), ast_netsock_release(), ast_smdi_interface_destroy(), load_module(), reload_config(), and unload_module().
#define ASTOBJ_CONTAINER_DUMP | ( | fd, | |||
s, | |||||
slen, | |||||
container | ) | ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, "%s", s); } while(0)) |
Dump information about all the objects in a container to a file descriptor.
fd | The file descriptor to write to. | |
s | A string buffer, same as ASTOBJ_DUMP(). | |
slen | The length of s, same as ASTOBJ_DUMP(). | |
container | A pointer to the container to dump. |
This macro dumps a text representation of the name, objectflags, and refcount fields of all the objects in a container to the specified file descriptor.
Definition at line 814 of file astobj.h.
Referenced by sip_show_objects().
#define ASTOBJ_CONTAINER_FIND | ( | container, | |||
namestr | ) |
Find an object in a container.
container | A pointer to the container to search. | |
namestr | The name to search for. |
Use this function to find an object with the specfied name in a container.
Definition at line 401 of file astobj.h.
Referenced by acf_jabberstatus_read(), aji_cli_create_collection(), aji_cli_create_leafnode(), aji_cli_delete_pubsub_node(), aji_cli_list_pubsub_nodes(), aji_cli_purge_pubsub_nodes(), aji_client_info_handler(), aji_create_buddy(), aji_create_client(), aji_dinfo_handler(), aji_handle_presence(), aji_handle_subscribe(), aji_register_query_handler(), aji_status_exec(), ast_aji_get_client(), ast_smdi_interface_find(), find_alias(), find_gtalk(), find_jingle(), find_peer(), find_user(), gtalk_alloc(), gtalk_create_member(), jingle_alloc(), jingle_create_member(), and smdi_load().
#define ASTOBJ_CONTAINER_FIND_FULL | ( | container, | |||
data, | |||||
field, | |||||
hashfunc, | |||||
hashoffset, | |||||
comparefunc | ) |
Find an object in a container.
container | A pointer to the container to search. | |
data | The data to search for. | |
field | The field/member of the container's objects to search. | |
hashfunc | The hash function to use, currently not implemented. | |
hashoffset | The hash offset to use, currently not implemented. | |
comparefunc | The function used to compare the field and data values. |
This macro iterates through a container passing the specified field and data elements to the specified comparefunc. The function should return 0 when a match is found.
Definition at line 428 of file astobj.h.
Referenced by find_gtalk(), find_jingle(), find_peer(), and find_user().
#define ASTOBJ_CONTAINER_FIND_UNLINK | ( | container, | |||
namestr | ) |
Find and remove an object from a container.
container | A pointer to the container to operate on. | |
namestr | The name of the object to remove. |
This macro iterates through a container and removes the first object with the specfied name from the container.
#define ASTOBJ_CONTAINER_FIND_UNLINK_FULL | ( | container, | |||
data, | |||||
field, | |||||
hashfunc, | |||||
hashoffset, | |||||
comparefunc | ) |
Find and remove an object in a container.
container | A pointer to the container to search. | |
data | The data to search for. | |
field | The field/member of the container's objects to search. | |
hashfunc | The hash function to use, currently not implemented. | |
hashoffset | The hash offset to use, currently not implemented. | |
comparefunc | The function used to compare the field and data values. |
This macro iterates through a container passing the specified field and data elements to the specified comparefunc. The function should return 0 when a match is found. If a match is found it is removed from the list.
Definition at line 551 of file astobj.h.
Referenced by build_alias(), build_peer(), and build_user().
#define ASTOBJ_CONTAINER_INIT | ( | container | ) | ASTOBJ_CONTAINER_INIT_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS) |
Initialize a container.
container | A pointer to the container to initialize. |
This macro initializes a container. It should only be used on containers that support locking.
Sample Usage:
struct sample_struct_container { ASTOBJ_CONTAINER_COMPONENTS(struct sample_struct); } container; int func() { ASTOBJ_CONTAINER_INIT(&container); }
Definition at line 752 of file astobj.h.
Referenced by aji_create_client(), alloc_smdi_interface(), ast_netsock_init(), and load_module().
#define ASTOBJ_CONTAINER_INIT_FULL | ( | container, | |||
hashes, | |||||
buckets | ) |
do { \ ast_mutex_init(&(container)->_lock); \ } while(0)
Initialize a container.
container | A pointer to the container to initialize. | |
hashes | Currently unused. | |
buckets | Currently unused. |
This macro initializes a container. It should only be used on containers that support locking.
Sample Usage:
struct sample_struct_container { ASTOBJ_CONTAINER_COMPONENTS_FULL(struct sample_struct,1,1); } container; int func() { ASTOBJ_CONTAINER_INIT_FULL(&container,1,1); }
#define ASTOBJ_CONTAINER_LINK | ( | container, | |||
newobj | ) | ASTOBJ_CONTAINER_LINK_FULL(container,newobj,(newobj)->name,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp) |
Add an object to a container.
container | A pointer to the container to operate on. | |
newobj | A pointer to the object to be added. |
Currently this macro adds an object to the head of a container. One day it should add an object in alphabetical order.
Definition at line 776 of file astobj.h.
Referenced by aji_create_buddy(), aji_create_client(), ast_netsock_bindaddr(), gtalk_load_config(), jingle_load_config(), reload_config(), sip_register(), sip_subscribe_mwi(), and smdi_load().
#define ASTOBJ_CONTAINER_LINK_END | ( | container, | |||
newobj | ) |
Add an object to the end of a container.
container | A pointer to the container to operate on. | |
newobj | A pointer to the object to be added. |
This macro adds an object to the end of a container.
Definition at line 580 of file astobj.h.
Referenced by ast_smdi_md_message_push(), and ast_smdi_mwi_message_push().
#define ASTOBJ_CONTAINER_LINK_FULL | ( | container, | |||
newobj, | |||||
data, | |||||
field, | |||||
hashfunc, | |||||
hashoffset, | |||||
comparefunc | ) |
Add an object to a container.
container | A pointer to the container to operate on. | |
newobj | A pointer to the object to be added. | |
data | Currently unused. | |
field | Currently unused. | |
hashfunc | Currently unused. | |
hashoffset | Currently unused. | |
comparefunc | Currently unused. |
Currently this function adds an object to the head of the list. One day it will support adding objects atthe position specified using the various options this macro offers.
#define ASTOBJ_CONTAINER_LINK_START | ( | container, | |||
newobj | ) |
Add an object to the front of a container.
container | A pointer to the container to operate on. | |
newobj | A pointer to the object to be added. |
This macro adds an object to the start of a container.
Definition at line 610 of file astobj.h.
Referenced by ast_smdi_md_message_putback(), and ast_smdi_mwi_message_putback().
#define ASTOBJ_CONTAINER_MARKALL | ( | container | ) | ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_MARK(iterator)) |
Mark all the objects in a container.
container | A pointer to the container to operate on. |
Definition at line 782 of file astobj.h.
Referenced by aji_create_client(), aji_reload(), and smdi_load().
#define ASTOBJ_CONTAINER_PRUNE_MARKED | ( | container, | |||
destructor | ) |
Prune marked objects from a container.
container | A pointer to the container to prune. | |
destructor | A destructor function to call on each marked object. |
This macro iterates through the specfied container and prunes any marked objects executing the specfied destructor if necessary.
Definition at line 651 of file astobj.h.
Referenced by aji_reload(), delete_aliases(), delete_users(), prune_peers(), and smdi_load().
Lock an ASTOBJ_CONTAINER for reading.
Definition at line 276 of file astobj.h.
Referenced by smdi_load().
#define ASTOBJ_CONTAINER_TRAVERSE | ( | container, | |||
continue, | |||||
eval | ) |
Iterate through the objects in a container.
container | A pointer to the container to traverse. | |
continue | A condition to allow the traversal to continue. | |
eval | A statement to evaluate in the iteration loop. |
This is macro is a little complicated, but it may help to think of it as a loop. Basically it iterates through the specfied containter as long as the condition is met. Two variables, iterator and next, are provided for use in your eval
statement. See the sample code for an example.
Sample Usage:
ASTOBJ_CONTAINER_TRAVERSE(&sample_container,1, { ASTOBJ_RDLOCK(iterator); printf("Currently iterating over '%s'\n", iterator->name); ASTOBJ_UNLOCK(iterator); } );
ASTOBJ_CONTAINER_TRAVERSE(&sample_container,1, sample_func(iterator));
Definition at line 376 of file astobj.h.
Referenced by aji_create_affiliations(), aji_do_set_debug(), aji_filter_roster(), aji_pruneregister(), aji_reload(), aji_show_buddies(), aji_show_clients(), ast_aji_get_client(), ast_netsock_find(), cleanup_all_regs(), delete_aliases(), delete_users(), find_gtalk(), find_jingle(), gtalk_load_config(), gtalk_show_channels(), jingle_load_config(), jingle_show_channels(), manager_show_registry(), reload_config(), sip_send_all_mwi_subscriptions(), sip_send_all_registers(), sip_show_mwi(), sip_show_registry(), smdi_msg_find(), and unload_module().
#define ASTOBJ_CONTAINER_UNLINK | ( | container, | |||
obj | ) |
Remove an object from a container.
container | A pointer to the container to operate on. | |
obj | A pointer to the object to remove. |
This macro iterates through a container and removes the specfied object if it exists in the container.
#define ASTOBJ_CONTAINER_UNLINK_START | ( | container | ) |
Remove an object from the front of a container.
container | A pointer to the container to operate on. |
This macro removes the first object in a container.
Definition at line 630 of file astobj.h.
Referenced by unlink_from_msg_q().
Unlock an ASTOBJ_CONTAINER.
Definition at line 283 of file astobj.h.
Referenced by delete_aliases(), delete_users(), reload_config(), and smdi_load().
Lock an ASTOBJ_CONTAINER for writing.
Definition at line 280 of file astobj.h.
Referenced by delete_aliases(), delete_users(), and reload_config().
#define ASTOBJ_DUMP | ( | s, | |||
slen, | |||||
obj | ) | snprintf((s),(slen),"name: %s\nobjflags: %u\nrefcount: %u\n\n", (obj)->name, (obj)->objflags, (obj)->refcount); |
Dump information about an object into a string.
s | A pointer to the string buffer to use. | |
slen | The length of s. | |
obj | A pointer to the object to dump. |
This macro dumps a text representation of the name, objectflags, and refcount fields of an object to the specfied string buffer.
#define ASTOBJ_INIT | ( | object | ) |
do { \ ast_mutex_init(&(object)->_lock); \ object->name[0] = '\0'; \ object->refcount = 1; \ } while(0)
Initialize an object.
object | A pointer to the object to operate on. |
Definition at line 264 of file astobj.h.
Referenced by aji_create_buddy(), aji_create_client(), alloc_smdi_interface(), ast_netsock_bindaddr(), build_alias(), build_peer(), build_user(), gtalk_load_config(), jingle_load_config(), sip_register(), sip_subscribe_mwi(), and smdi_read().
#define ASTOBJ_MARK | ( | object | ) |
do { \ ASTOBJ_WRLOCK(object); \ (object)->objflags |= ASTOBJ_FLAG_MARKED; \ ASTOBJ_UNLOCK(object); \ } while(0)
Mark an ASTOBJ by adding the ASTOBJ_FLAG_MARKED flag to its objflags mask.
object | A pointer to the object to operate on. |
This macro "marks" an object. Marked objects can later be unlinked from a container using ASTOBJ_CONTAINER_PRUNE_MARKED().
Definition at line 241 of file astobj.h.
Referenced by delete_aliases(), and delete_users().
#define ASTOBJ_RDLOCK | ( | object | ) | ast_mutex_lock(&(object)->_lock) |
Lock an ASTOBJ for reading.
Definition at line 100 of file astobj.h.
Referenced by aji_create_affiliations(), aji_do_set_debug(), aji_filter_roster(), aji_pruneregister(), aji_reload(), aji_show_buddies(), aji_show_clients(), ast_netsock_find(), delete_aliases(), delete_users(), find_gtalk(), find_jingle(), manager_show_registry(), reload_config(), sip_show_mwi(), and sip_show_registry().
#define ASTOBJ_REF | ( | object | ) |
Increment an object reference count.
object | A pointer to the object to operate on. |
Definition at line 201 of file astobj.h.
Referenced by __sip_subscribe_mwi_do(), aji_act_hook(), aji_client_connect(), aji_client_info_handler(), aji_delete_node_list(), aji_devstate_cb(), aji_dinfo_handler(), aji_ditems_handler(), aji_filter_roster(), aji_handle_pubsub_error(), aji_log_hook(), aji_mwi_cb(), aji_receive_node_list(), aji_recv_loop(), aji_register_approve_handler(), aji_register_query_handler(), append_mailbox_mapping(), ast_aji_get_client(), gtalk_parser(), handle_response_subscribe(), jingle_parser(), registry_addref(), sip_send_all_mwi_subscriptions(), smdi_msg_find(), and smdi_msg_retrieve_read().
#define ASTOBJ_TRYWRLOCK | ( | object | ) | ast_mutex_trylock(&(object)->_lock) |
#define ASTOBJ_UNLOCK | ( | object | ) | ast_mutex_unlock(&(object)->_lock) |
Unlock a locked object.
Definition at line 109 of file astobj.h.
Referenced by aji_create_affiliations(), aji_create_buddy(), aji_create_client(), aji_do_set_debug(), aji_filter_roster(), aji_handle_presence(), aji_reload(), aji_show_buddies(), aji_show_clients(), ast_netsock_find(), cleanup_all_regs(), delete_aliases(), delete_users(), find_gtalk(), find_jingle(), gtalk_load_config(), gtalk_request(), gtalk_show_channels(), jingle_load_config(), jingle_request(), jingle_show_channels(), manager_show_registry(), reload_config(), sip_send_all_mwi_subscriptions(), sip_send_all_registers(), sip_show_mwi(), sip_show_registry(), smdi_toggle_mwi(), and unload_module().
#define ASTOBJ_UNMARK | ( | object | ) |
do { \ ASTOBJ_WRLOCK(object); \ (object)->objflags &= ~ASTOBJ_FLAG_MARKED; \ ASTOBJ_UNLOCK(object); \ } while(0)
Unmark an ASTOBJ by subtracting the ASTOBJ_FLAG_MARKED flag from its objflags mask.
object | A pointer to the object to operate on. |
Definition at line 251 of file astobj.h.
Referenced by aji_create_buddy(), aji_create_client(), build_alias(), build_peer(), build_user(), and smdi_load().
#define ASTOBJ_UNREF | ( | object, | |||
destructor | ) |
Decrement the reference count on an object.
object | A pointer the object to operate on. | |
destructor | The destructor to call if the object is no longer referenced. It will be passed the pointer as an argument. |
This macro unreferences an object and calls the specfied destructor if the object is no longer referenced. The destructor should free the object if it was dynamically allocated.
Definition at line 218 of file astobj.h.
Referenced by __analog_ss_thread(), __sip_subscribe_mwi_do(), acf_jabberreceive_read(), acf_jabberstatus_read(), aji_act_hook(), aji_cli_create_collection(), aji_cli_create_leafnode(), aji_cli_delete_pubsub_node(), aji_cli_list_pubsub_nodes(), aji_cli_purge_pubsub_nodes(), aji_client_connect(), aji_client_info_handler(), aji_create_buddy(), aji_create_client(), aji_devstate_cb(), aji_dinfo_handler(), aji_ditems_handler(), aji_handle_presence(), aji_handle_pubsub_error(), aji_handle_subscribe(), aji_join_exec(), aji_leave_exec(), aji_log_hook(), aji_mwi_cb(), aji_receive_node_list(), aji_recv_loop(), aji_register_approve_handler(), aji_register_query_handler(), aji_send_exec(), aji_sendgroup_exec(), aji_status_exec(), analog_ss_thread(), ast_aji_disconnect(), ast_netsock_unref(), ast_smdi_interface_unref(), build_peer(), build_user(), create_addr(), destroy_mailbox_mapping(), gtalk_alloc(), gtalk_load_config(), gtalk_newcall(), gtalk_parser(), gtalk_request(), handle_response_subscribe(), jingle_alloc(), jingle_load_config(), jingle_newcall(), jingle_parser(), jingle_request(), manager_jabber_send(), registry_unref(), reload_config(), run_externnotify(), setup_incoming_call(), sip_send_all_mwi_subscriptions(), sip_subscribe_mwi(), sip_subscribe_mwi_do(), smdi_load(), smdi_msg_datastore_destroy(), smdi_msg_retrieve_read(), smdi_read(), unload_module(), and unref_msg().
#define ASTOBJ_WRLOCK | ( | object | ) | ast_mutex_lock(&(object)->_lock) |
Lock an ASTOBJ for writing.
Definition at line 104 of file astobj.h.
Referenced by aji_create_buddy(), aji_create_client(), aji_handle_presence(), cleanup_all_regs(), gtalk_load_config(), gtalk_request(), gtalk_show_channels(), jingle_load_config(), jingle_request(), jingle_show_channels(), sip_send_all_mwi_subscriptions(), sip_send_all_registers(), smdi_toggle_mwi(), and unload_module().