Genericize the allocation and destruction of taskprocessor listeners.

The goal of this is to take the responsibility away from individual
listeners to be sure to properly unref the taskprocessor.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376121 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2012-11-09 22:28:10 +00:00
parent 6fc8d830f8
commit d5716ecae2
3 changed files with 61 additions and 26 deletions

View File

@@ -63,10 +63,14 @@ enum ast_tps_options {
struct ast_taskprocessor_listener;
struct ast_taskprocessor_listener_callbacks {
/*! Allocate the listener's private data */
void *(*alloc)(struct ast_taskprocessor_listener *listener);
/*! Indicates a task was pushed to the processor */
void (*task_pushed)(struct ast_taskprocessor_listener *listener, int was_empty);
/*! Indicates the task processor has become empty */
void (*emptied)(struct ast_taskprocessor_listener *listener);
/*! Destroy the listener's private data */
void (*destroy)(void *private_data);
};
struct ast_taskprocessor_listener {
@@ -75,6 +79,9 @@ struct ast_taskprocessor_listener {
void *private_data;
};
struct ast_taskprocessor_listener *ast_taskprocessor_listener_alloc(struct ast_taskprocessor *tps,
struct ast_taskprocessor_listener_callbacks *callbacks);
/*!
* \brief Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary
*