diff options
author | Corey Farrell <git@cfware.com> | 2016-08-26 14:18:10 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2016-09-02 09:13:33 -0400 |
commit | 0c5b6e9ff559dcb20d9315154d4bd6a2ea5aa6a9 (patch) | |
tree | f4cb82f8974311b1b1b839a9d41c2891dba3ebcc /include/asterisk/astobj2.h | |
parent | d3c4b901d476a41b3f7df063aeba3852df4e26b7 (diff) |
astobj2: Support using a separate object for locking.
Create ao2_alloc_with_lockobj function to support shared locking.
Change-Id: Iba687eb9843922be7e481e23a32c0700ecf88a80
Diffstat (limited to 'include/asterisk/astobj2.h')
-rw-r--r-- | include/asterisk/astobj2.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h index 0472c1b37..28ae73e87 100644 --- a/include/asterisk/astobj2.h +++ b/include/asterisk/astobj2.h @@ -368,6 +368,13 @@ enum ao2_alloc_opts { AO2_ALLOC_OPT_LOCK_NOLOCK = (2 << 0), /*! The ao2 object locking option field mask. */ AO2_ALLOC_OPT_LOCK_MASK = (3 << 0), + /*! + * \internal The ao2 object uses a separate object for locking. + * + * \note This option is used internally by ao2_alloc_with_lockobj and + * should never be passed directly to ao2_alloc. + */ + AO2_ALLOC_OPT_LOCK_OBJ = AO2_ALLOC_OPT_LOCK_MASK, }; /*! @@ -408,6 +415,26 @@ void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned in /*! @} */ +/*! + * \since 14.1.0 + * \brief Allocate and initialize an object with separate locking. + * + * \param data_size The sizeof() of the user-defined structure. + * \param destructor_fn The destructor function (can be NULL) + * \param lockobj A separate ao2 object that will provide locking. + * \param debug_msg An ao2 object debug tracing message. + * \return A pointer to user-data. + * + * \see \ref ao2_alloc for additional details. + * + * \note lockobj must be a valid AO2 object. + */ +#define ao2_alloc_with_lockobj(data_size, destructor_fn, lockobj, tag) \ + __ao2_alloc_with_lockobj((data_size), (destructor_fn), (lockobj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) + +void *__ao2_alloc_with_lockobj(size_t data_size, ao2_destructor_fn destructor_fn, void *lockobj, + const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result; + /*! \brief * Reference/unreference an object and return the old refcount. * |