[svn-commits] mmichelson: branch mmichelson/threadpool r376119 - /team/mmichelson/threadpoo...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Nov 8 17:35:13 CST 2012
Author: mmichelson
Date: Thu Nov 8 17:35:10 2012
New Revision: 376119
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=376119
Log:
Get rid of taskprocessor fields no longer necessary.
This includes changing the taskprocessor to use its builtin
ao2_lock instead of having a separate mutex. It can do this
now since there is no longer an ast_cond_t associated with
the taskprocessor.
Modified:
team/mmichelson/threadpool/main/taskprocessor.c
Modified: team/mmichelson/threadpool/main/taskprocessor.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/main/taskprocessor.c?view=diff&rev=376119&r1=376118&r2=376119
==============================================================================
--- team/mmichelson/threadpool/main/taskprocessor.c (original)
+++ team/mmichelson/threadpool/main/taskprocessor.c Thu Nov 8 17:35:10 2012
@@ -67,14 +67,6 @@
struct ast_taskprocessor {
/*! \brief Friendly name of the taskprocessor */
const char *name;
- /*! \brief Thread poll condition */
- ast_cond_t poll_cond;
- /*! \brief Taskprocessor thread */
- pthread_t poll_thread;
- /*! \brief Taskprocessor lock */
- ast_mutex_t taskprocessor_lock;
- /*! \brief Taskprocesor thread run flag */
- unsigned char poll_thread_run;
/*! \brief Taskprocessor statistics */
struct tps_taskprocessor_stats *stats;
/*! \brief Taskprocessor current queue size */
@@ -392,8 +384,6 @@
return;
}
ast_debug(1, "destroying taskprocessor '%s'\n", t->name);
- /* kill it */
- ast_mutex_destroy(&t->taskprocessor_lock);
/* free it */
if (t->stats) {
ast_free(t->stats);
@@ -419,11 +409,11 @@
ast_log(LOG_ERROR, "missing taskprocessor\n");
return NULL;
}
- ast_mutex_lock(&tps->taskprocessor_lock);
+ ao2_lock(tps);
if ((task = AST_LIST_REMOVE_HEAD(&tps->tps_queue, list))) {
tps->tps_queue_size--;
}
- ast_mutex_unlock(&tps->taskprocessor_lock);
+ ao2_unlock(tps);
return task;
}
@@ -573,10 +563,10 @@
ast_log(LOG_ERROR, "failed to allocate task! Can't push to '%s'\n", tps->name);
return -1;
}
- ast_mutex_lock(&tps->taskprocessor_lock);
+ ao2_lock(tps);
AST_LIST_INSERT_TAIL(&tps->tps_queue, t, list);
previous_size = tps->tps_queue_size++;
- ast_mutex_unlock(&tps->taskprocessor_lock);
+ ao2_unlock(tps);
tps->listener->callbacks->task_pushed(tps->listener, previous_size ? 0 : 1);
return 0;
}
@@ -594,7 +584,7 @@
tps_task_free(t);
- ast_mutex_lock(&tps->taskprocessor_lock);
+ ao2_lock(tps);
size = tps_taskprocessor_depth(tps);
if (tps->stats) {
tps->stats->_tasks_processed_count++;
@@ -602,7 +592,7 @@
tps->stats->max_qsize = size;
}
}
- ast_mutex_unlock(&tps->taskprocessor_lock);
+ ao2_unlock(tps);
if (size == 0) {
tps->listener->callbacks->emptied(tps->listener);
More information about the svn-commits
mailing list