[asterisk-commits] dlee: branch dlee/taskprocessor-optimization r399653 - /team/dlee/taskprocess...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 23 23:58:26 CDT 2013


Author: dlee
Date: Mon Sep 23 23:58:24 2013
New Revision: 399653

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399653
Log:
Taskprocessor lock optimization

Modified:
    team/dlee/taskprocessor-optimization/main/taskprocessor.c

Modified: team/dlee/taskprocessor-optimization/main/taskprocessor.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/taskprocessor-optimization/main/taskprocessor.c?view=diff&rev=399653&r1=399652&r2=399653
==============================================================================
--- team/dlee/taskprocessor-optimization/main/taskprocessor.c (original)
+++ team/dlee/taskprocessor-optimization/main/taskprocessor.c Mon Sep 23 23:58:24 2013
@@ -439,7 +439,6 @@
 static struct tps_task *tps_taskprocessor_pop(struct ast_taskprocessor *tps)
 {
 	struct tps_task *task;
-	SCOPED_AO2LOCK(lock, tps);
 
 	if ((task = AST_LIST_REMOVE_HEAD(&tps->tps_queue, list))) {
 		tps->tps_queue_size--;
@@ -661,15 +660,17 @@
 	int size;
 
 	ao2_lock(tps);
+	t = tps_taskprocessor_pop(tps);
+	if (!t) {
+		ao2_unlock(tps);
+		return 0;
+	}
+
 	tps->executing = 1;
 	ao2_unlock(tps);
 
-	t = tps_taskprocessor_pop(tps);
-
-	if (t) {
-		t->execute(t->datap);
-		tps_task_free(t);
-	}
+	t->execute(t->datap);
+	tps_task_free(t);
 
 	ao2_lock(tps);
 	/* We need to check size in the same critical section where we reset the
@@ -679,7 +680,7 @@
 	tps->executing = 0;
 	size = tps_taskprocessor_depth(tps);
 	/* If we executed a task, bump the stats */
-	if (t && tps->stats) {
+	if (tps->stats) {
 		tps->stats->_tasks_processed_count++;
 		if (size > tps->stats->max_qsize) {
 			tps->stats->max_qsize = size;
@@ -688,7 +689,7 @@
 	ao2_unlock(tps);
 
 	/* If we executed a task, check for the transition to empty */
-	if (t && size == 0 && tps->listener->callbacks->emptied) {
+	if (size == 0 && tps->listener->callbacks->emptied) {
 		tps->listener->callbacks->emptied(tps->listener);
 	}
 	return size > 0;




More information about the asterisk-commits mailing list