[svn-commits] mmichelson: branch mmichelson/threadpool r377210 - /team/mmichelson/threadpoo...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 4 15:21:18 CST 2012


Author: mmichelson
Date: Tue Dec  4 15:21:15 2012
New Revision: 377210

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377210
Log:
Simplify threadpool refcounting a bit.

Since threadpool shutdown is very strictly controlled,
there is no need to be so precise with reference counts
in queued operations. Since the threadpool shuts down its
own control taskprocessor before doing anything else destructive,
it can be guaranteed that all queued tasks will have a valid
pointer to the pool. This meant that some destructor functions
for helper structs could be removed entirely.


Modified:
    team/mmichelson/threadpool/main/threadpool.c

Modified: team/mmichelson/threadpool/main/threadpool.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/main/threadpool.c?view=diff&rev=377210&r1=377209&r2=377210
==============================================================================
--- team/mmichelson/threadpool/main/threadpool.c (original)
+++ team/mmichelson/threadpool/main/threadpool.c Tue Dec  4 15:21:15 2012
@@ -161,7 +161,6 @@
 static void thread_worker_pair_destructor(void *obj)
 {
 	struct thread_worker_pair *pair = obj;
-	ao2_ref(pair->pool, -1);
 	ao2_ref(pair->worker, -1);
 }
 
@@ -177,7 +176,6 @@
 	if (!pair) {
 		return NULL;
 	}
-	ao2_ref(pool, +1);
 	pair->pool = pool;
 	ao2_ref(worker, +1);
 	pair->worker = worker;
@@ -346,15 +344,6 @@
 };
 
 /*!
- * \brief Destructor for task_pushed_data
- */
-static void task_pushed_data_destroy(void *obj)
-{
-	struct task_pushed_data *tpd = obj;
-	ao2_ref(tpd->pool, -1);
-}
-
-/*!
  * \brief Allocate and initialize a task_pushed_data
  * \param pool The threadpool to set in the task_pushed_data
  * \param was_empty The was_empty value to set in the task_pushed_data
@@ -364,13 +353,11 @@
 static struct task_pushed_data *task_pushed_data_alloc(struct ast_threadpool *pool,
 		int was_empty)
 {
-	struct task_pushed_data *tpd = ao2_alloc(sizeof(*tpd),
-			task_pushed_data_destroy);
+	struct task_pushed_data *tpd = ao2_alloc(sizeof(*tpd), NULL);
 
 	if (!tpd) {
 		return NULL;
 	}
-	ao2_ref(pool, +1);
 	tpd->pool = pool;
 	tpd->was_empty = was_empty;
 	return tpd;
@@ -454,7 +441,6 @@
 	struct ast_threadpool *pool = data;
 
 	pool->listener->callbacks->emptied(pool->listener);
-	ao2_ref(pool, -1);
 	return 0;
 }
 
@@ -469,7 +455,6 @@
 {
 	struct ast_threadpool *pool = listener->private_data;
 
-	ao2_ref(pool, +1);
 	ast_taskprocessor_push(pool->control_tps, handle_emptied, pool);
 }
 
@@ -637,16 +622,6 @@
 };
 
 /*!
- * \brief Destructor for set_size_data
- * \param obj The set_size_data to destroy
- */
-static void set_size_data_destroy(void *obj)
-{
-	struct set_size_data *ssd = obj;
-	ao2_ref(ssd->pool, -1);
-}
-
-/*!
  * \brief Allocate and initialize a set_size_data
  * \param pool The pool for the set_size_data
  * \param size The size to store in the set_size_data
@@ -659,7 +634,6 @@
 		return NULL;
 	}
 
-	ao2_ref(pool, +1);
 	ssd->pool = pool;
 	ssd->size = size;
 	return ssd;




More information about the svn-commits mailing list