[asterisk-commits] dhubbard: branch group/taskprocessors r114821 - /team/group/taskprocessors/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 28 21:56:10 CDT 2008
Author: dhubbard
Date: Mon Apr 28 21:56:09 2008
New Revision: 114821
URL: http://svn.digium.com/view/asterisk?view=rev&rev=114821
Log:
cheese
Modified:
team/group/taskprocessors/main/taskprocessor.c
Modified: team/group/taskprocessors/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/main/taskprocessor.c?view=diff&rev=114821&r1=114820&r2=114821
==============================================================================
--- team/group/taskprocessors/main/taskprocessor.c (original)
+++ team/group/taskprocessors/main/taskprocessor.c Mon Apr 28 21:56:09 2008
@@ -105,9 +105,8 @@
AST_CLI_DEFINE(cli_tps_report, "List instantiated task processors and statistics"),
};
-/*! \brief Perform necessary taskprocessor subsystem initialization stuff
- * \param void
- * \return 0
+/*
+ * Taskprocessor Subsystem
*/
int ast_tps_init(void)
{
@@ -119,11 +118,8 @@
return 0;
}
-/*! \brief Allocate a task structure
- * \param task_exe function for the taskprocessor to execute
- * \param datap data pointer for the task
- * \param src where the task came from, this is going to be debug only
- * \return A task prepared to be queued into a taskprocessor
+/*
+ * Task allocation & free
*/
struct ast_task *ast_task_alloc(int (*task_exe)(void *datap), void *datap, char *src)
{
@@ -136,10 +132,6 @@
return t;
}
-/*! \brief Release the task resources
- * \param task the task to be freed
- * \return 0 on success
- */
int ast_task_free(struct ast_task *task)
{
if (task) {
@@ -148,10 +140,8 @@
return 0;
}
-/*! \brief Tab completion function
- * \param p ast_taskprocessor structure
- * \param a CLI arguments
- * \return NULL
+/*
+ * Taskprocessor CLI
*/
static char *tps_taskprocessor_tab_complete(struct ast_taskprocessor *p, struct ast_cli_args *a)
{
@@ -178,10 +168,6 @@
return name;
}
-/*! \brief CLI 'taskprocessor ping <blah>' operation handler
- * \param task the ping task queued by the CLI operation
- * \return 0 on success, -1 on error
- */
static int tps_taskprocessor_ping_handler(void *datap)
{
ast_mutex_lock(&cli_ping_cond_lock);
@@ -190,12 +176,6 @@
return 0;
}
-/*! \brief CLI 'taskprocessor ping' operation queues a ping task to the specified taskprocessor
- * \param e CLI entries
- * \param cmd
- * \param a CLI arguments
- * \return CLI_SUCCESS on success, CLI_SHOWUSAGE on error
- */
static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct timeval begin, end, delta;
@@ -249,12 +229,6 @@
return CLI_SUCCESS;
}
-/*! \brief CLI 'taskprocessor show stats' operation lists all taskprocessors and their statistics
- * \param e CLI entries
- * \param cmd
- * \param a CLI arguments
- * \return CLI_SUCCESS on success, CLI_SHOWUSAGE on error
- */
static char *cli_tps_report(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
char name[256];
@@ -296,10 +270,8 @@
return CLI_SUCCESS;
}
-/*! \brief The default taskprocessing thread pops tasks off its queue and executes it
- * \param data ast_taskprocessor structure for the named thread
- * \note The default taskprocessor thread function can be overridden via ast_taskprocessor_get()
- * \return NULL
+/*
+ * Task processing
*/
static void *tps_default_processor_function(void *data)
{
@@ -357,8 +329,9 @@
}
return NULL;
}
-/*!
- * \note Taskprocessors are uniquely identified by name
+
+/*
+ * hashing and comparison
*/
static int tps_hash_cb(const void *obj, const int flags)
{
@@ -367,18 +340,15 @@
return ast_str_hash(tps->name);
}
-/*!
- * \note Taskprocessors are uniquely identified by name
- */
static int tps_cmp_cb(void *obj, void *arg, int flags)
{
struct ast_taskprocessor *lhs = obj, *rhs = arg;
return !strcasecmp(lhs->name, rhs->name) ? CMP_MATCH : 0;
}
-/*! \brief The default taskprocessor constructor creates an initialized taskprocessor structure
- * \param poll_freq The polling frequency of the taskprocessor
- * \return ast_taskprocessor structure on success, NULL on error
+
+/*
+ * Taskprocessor construction and destruction
*/
static struct ast_taskprocessor *tps_default_constructor(void)
{
@@ -396,8 +366,34 @@
return tps;
}
-/*! \brief Return the name of a taskprocessor singleton
- * \param tps pointer to a taskprocessor singleton */
+static void tps_taskprocessor_destroy(void *tps)
+{
+ struct ast_taskprocessor *t = tps;
+
+ if (!tps) {
+ ast_log(LOG_ERROR, "missing taskprocessor\n");
+ return;
+ }
+ ast_log(LOG_DEBUG, "destroying taskprocessor \'%s\'\n", t->name);
+ /* kill it */
+ ast_mutex_lock(&t->taskprocessor_lock);
+ t->poll_thread_run = 0;
+ ast_cond_signal(&t->poll_cond);
+ ast_mutex_unlock(&t->taskprocessor_lock);
+ pthread_join(t->poll_thread, NULL);
+ t->poll_thread = AST_PTHREADT_NULL;
+ /* free it */
+ if (t->stats) {
+ ast_free(t->stats);
+ t->stats = NULL;
+ }
+ ast_free(t->name);
+ return;
+}
+
+/*
+ * Taskprocessor service functions
+ */
char * ast_taskprocessor_name(struct ast_taskprocessor *tps)
{
if (!tps) {
@@ -407,11 +403,6 @@
return tps->name;
}
-/*! \brief Return a pointer to the taskprocessor singleton structure and create it if necessary.
- * \param name the name of the taskprocessor singleton
- * \param custom_func the function executed by the taskprocessor thread
- * \return ast_taskprocessor pointer on success, NULL on error
- */
struct ast_taskprocessor *ast_taskprocessor_get(char *name, void *(*custom_func)(void*), enum ast_tps_options create)
{
int rc;
@@ -491,40 +482,6 @@
return NULL;
}
-/*! \brief The taskprocessor destructor is called by astobj2 when the reference count reaches zero
- * \param tps ast_taskprocessor structure
- * \return void
- */
-static void tps_taskprocessor_destroy(void *tps)
-{
- struct ast_taskprocessor *t = tps;
-
- if (!tps) {
- ast_log(LOG_ERROR, "missing taskprocessor\n");
- return;
- }
- ast_log(LOG_DEBUG, "destroying taskprocessor \'%s\'\n", t->name);
- /* kill it */
- ast_mutex_lock(&t->taskprocessor_lock);
- t->poll_thread_run = 0;
- ast_cond_signal(&t->poll_cond);
- ast_mutex_unlock(&t->taskprocessor_lock);
- pthread_join(t->poll_thread, NULL);
- t->poll_thread = AST_PTHREADT_NULL;
- /* free it */
- if (t->stats) {
- ast_free(t->stats);
- t->stats = NULL;
- }
- ast_free(t->name);
- return;
-}
-
-/*! \brief Push a task into the taskprocessor queue
- * \param tps taskprocessor to push task
- * \param t task to push to taskprocessor
- * \return 0 on success, -1 on error
- */
int ast_taskprocessor_push(struct ast_taskprocessor *tps, struct ast_task *t)
{
if (!tps || !t) {
@@ -539,10 +496,6 @@
return 0;
}
-/*! \brief Pop the front task off the taskprocessor queue and return it to the caller
- * \param tps taskprocessor to pop task from
- * \return task on success, NULL on error
- */
struct ast_task *ast_taskprocessor_pop(struct ast_taskprocessor *tps)
{
struct ast_task *t;
@@ -559,10 +512,6 @@
return t;
}
-/*! \brief Return the number of tasks waiting in the taskprocessor queue
- * \param tps taskprocessor to return queue depth
- * \return depth on success, -1 on error
- */
int ast_taskprocessor_depth(struct ast_taskprocessor *tps)
{
int size = -1;
More information about the asterisk-commits
mailing list