mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 16:20:37 +00:00
Astobj2: Add ao2_weakproxy_ref_object function.
This function allows code to run ao2_ref against the real object associated with a weakproxy. It is useful when all of the following conditions are true: * You have a pointer to weakproxy. * You do not have or need a pointer to the real object. * You need to ensure the real object exists and is not destroyed during a process. In this case it's wasteful to store a pointer to the real object just for the sake of releasing it later. Change-Id: I38a319b83314de75be74207a8771aab269bcca46
This commit is contained in:
@@ -558,6 +558,29 @@ int __ao2_weakproxy_set_object(void *weakproxy, void *obj, int flags,
|
||||
#define ao2_t_weakproxy_set_object(weakproxy, obj, flags, tag) \
|
||||
__ao2_weakproxy_set_object(weakproxy, obj, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||
|
||||
/*!
|
||||
* \since 14.0.0
|
||||
* \brief Run ao2_t_ref on the object associated with weakproxy.
|
||||
*
|
||||
* \param weakproxy The weakproxy to read from.
|
||||
* \param delta Value to add to the reference counter.
|
||||
* \param flags OBJ_NOLOCK to avoid locking weakproxy.
|
||||
*
|
||||
* \retval -2 weakproxy is not a valid ao2_weakproxy.
|
||||
* \retval -1 weakproxy has no associated object.
|
||||
*
|
||||
* \return The value of the reference counter before the operation.
|
||||
*/
|
||||
int __ao2_weakproxy_ref_object(void *weakproxy, int delta, int flags,
|
||||
const char *tag, const char *file, int line, const char *func);
|
||||
|
||||
#define ao2_t_weakproxy_ref_object(weakproxy, delta, flags, tag) \
|
||||
__ao2_weakproxy_ref_object(weakproxy, delta, flags, \
|
||||
tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||
|
||||
#define ao2_weakproxy_ref_object(weakproxy, delta, flags) \
|
||||
ao2_t_weakproxy_ref_object(weakproxy, delta, flags, "")
|
||||
|
||||
/*!
|
||||
* \since 14.0.0
|
||||
* \brief Get the object associated with weakproxy.
|
||||
|
||||
Reference in New Issue
Block a user