summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2013-01-15 18:40:36 +0000
committerMark Michelson <mmichelson@digium.com>2013-01-15 18:40:36 +0000
commit65c7d6e2c3d4fc3a161a31ff1e89d20256926fb1 (patch)
tree8076acfcfd024cdfa45aea20a5fa908e6af34651 /include/asterisk
parentc80f86f007f6676f105a768be0ceedb3a8ec8298 (diff)
Remove alloc and destroy callbacks from the taskprocessor.
Now user data is allocated by the creator of the taskprocessor listener and that user data is passed into ast_taskprocessor_listener_alloc(). Similarly, freeing of the user data is left up to the user himself. He can free the data when the taskprocessor shuts down, or he can choose to hold onto it if it makes sense to do so. This, unsurprisingly, makes threadpool allocation a LOT cleaner now. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/taskprocessor.h28
1 files changed, 5 insertions, 23 deletions
diff --git a/include/asterisk/taskprocessor.h b/include/asterisk/taskprocessor.h
index 7720547d6..c64a8f902 100644
--- a/include/asterisk/taskprocessor.h
+++ b/include/asterisk/taskprocessor.h
@@ -75,17 +75,6 @@ struct ast_taskprocessor_listener;
struct ast_taskprocessor_listener_callbacks {
/*!
- * \brief Allocate the listener's private data
- *
- * This is called during taskprocesor creation.
- * It is not necessary to assign the private data to the listener.
- *
- * \param listener The listener to which the private data belongs
- * \retval NULL Error while attempting to initialize private data
- * \retval non-NULL Allocated private data
- */
- void *(*alloc)(struct ast_taskprocessor_listener *listener);
- /*!
* \brief The taskprocessor has started completely
*
* This indicates that the taskprocessor is fully set up and the listener
@@ -111,7 +100,8 @@ struct ast_taskprocessor_listener_callbacks {
* \brief Indicates the taskprocessor wishes to die.
*
* All operations on the task processor must to be stopped in
- * this callback.
+ * this callback. This is an opportune time to free the listener's
+ * user data if it is not going to be used anywhere else.
*
* After this callback returns, it is NOT safe to operate on the
* listener's reference to the taskprocessor.
@@ -119,15 +109,6 @@ struct ast_taskprocessor_listener_callbacks {
* \param listener The listener
*/
void (*shutdown)(struct ast_taskprocessor_listener *listener);
- /*!
- * \brief Destroy the listener's private data
- *
- * It is required that you free the private data in this callback
- * in addition to the private data's individual fields.
- *
- * \param private_data The listener's private data
- */
- void (*destroy)(void *private_data);
};
/*!
@@ -146,7 +127,7 @@ struct ast_taskprocessor_listener {
/*! The taskprocessor that the listener is listening to */
struct ast_taskprocessor *tps;
/*! Data private to the listener */
- void *private_data;
+ void *user_data;
};
/*!
@@ -158,10 +139,11 @@ struct ast_taskprocessor_listener {
* callbacks.
*
* \param callbacks The callbacks to assign to the listener
+ * \param user_data The user data for the listener
* \retval NULL Failure
* \retval non-NULL The newly allocated taskprocessor listener
*/
-struct ast_taskprocessor_listener *ast_taskprocessor_listener_alloc(const struct ast_taskprocessor_listener_callbacks *callbacks);
+struct ast_taskprocessor_listener *ast_taskprocessor_listener_alloc(const struct ast_taskprocessor_listener_callbacks *callbacks, void *user_data);
/*!
* \brief Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary