[asterisk-commits] mmichelson: branch mmichelson/threadpool r379125 - in /team/mmichelson/thread...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 15 14:48:49 CST 2013


Author: mmichelson
Date: Tue Jan 15 14:48:45 2013
New Revision: 379125

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379125
Log:
Make ast_taskprocessor_listener opaque.


Modified:
    team/mmichelson/threadpool/include/asterisk/taskprocessor.h
    team/mmichelson/threadpool/main/taskprocessor.c
    team/mmichelson/threadpool/main/threadpool.c
    team/mmichelson/threadpool/tests/test_taskprocessor.c

Modified: team/mmichelson/threadpool/include/asterisk/taskprocessor.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/include/asterisk/taskprocessor.h?view=diff&rev=379125&r1=379124&r2=379125
==============================================================================
--- team/mmichelson/threadpool/include/asterisk/taskprocessor.h (original)
+++ team/mmichelson/threadpool/include/asterisk/taskprocessor.h Tue Jan 15 14:48:45 2013
@@ -111,24 +111,8 @@
 	void (*shutdown)(struct ast_taskprocessor_listener *listener);
 };
 
-/*!
- * \brief A listener for taskprocessors
- *
- * \since 12.0.0
- *
- * When a taskprocessor's state changes, the listener
- * is notified of the change. This allows for tasks
- * to be addressed in whatever way is appropriate for
- * the module using the taskprocessor.
- */
-struct ast_taskprocessor_listener {
-	/*! The callbacks the taskprocessor calls into to notify of state changes */
-	const struct ast_taskprocessor_listener_callbacks *callbacks;
-	/*! The taskprocessor that the listener is listening to */
-	struct ast_taskprocessor *tps;
-	/*! Data private to the listener */
-	void *user_data;
-};
+struct ast_taskprocessor *ast_taskprocessor_listener_get_tps(const struct ast_taskprocessor_listener *listener);
+void *ast_taskprocessor_listener_get_user_data(const struct ast_taskprocessor_listener *listener);
 
 /*!
  * \brief Allocate a taskprocessor listener

Modified: team/mmichelson/threadpool/main/taskprocessor.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/main/taskprocessor.c?view=diff&rev=379125&r1=379124&r2=379125
==============================================================================
--- team/mmichelson/threadpool/main/taskprocessor.c (original)
+++ team/mmichelson/threadpool/main/taskprocessor.c Tue Jan 15 14:48:45 2013
@@ -78,6 +78,26 @@
 	/*! Indicates if the taskprocessor is in the process of shuting down */
 	unsigned int shutting_down:1;
 };
+
+/*!
+ * \brief A listener for taskprocessors
+ *
+ * \since 12.0.0
+ *
+ * When a taskprocessor's state changes, the listener
+ * is notified of the change. This allows for tasks
+ * to be addressed in whatever way is appropriate for
+ * the module using the taskprocessor.
+ */
+struct ast_taskprocessor_listener {
+	/*! The callbacks the taskprocessor calls into to notify of state changes */
+	const struct ast_taskprocessor_listener_callbacks *callbacks;
+	/*! The taskprocessor that the listener is listening to */
+	struct ast_taskprocessor *tps;
+	/*! Data private to the listener */
+	void *user_data;
+};
+
 #define TPS_MAX_BUCKETS 7
 /*! \brief tps_singletons is the astobj2 container for taskprocessor singletons */
 static struct ao2_container *tps_singletons;
@@ -473,6 +493,16 @@
 	return listener;
 }
 
+struct ast_taskprocessor *ast_taskprocessor_listener_get_tps(const struct ast_taskprocessor_listener *listener)
+{
+	return listener->tps;
+}
+
+void *ast_taskprocessor_listener_get_user_data(const struct ast_taskprocessor_listener *listener)
+{
+	return listener->user_data;
+}
+
 static void *default_listener_pvt_alloc(void)
 {
 	struct default_taskprocessor_listener_pvt *pvt;

Modified: team/mmichelson/threadpool/main/threadpool.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/main/threadpool.c?view=diff&rev=379125&r1=379124&r2=379125
==============================================================================
--- team/mmichelson/threadpool/main/threadpool.c (original)
+++ team/mmichelson/threadpool/main/threadpool.c Tue Jan 15 14:48:45 2013
@@ -548,7 +548,7 @@
 static void threadpool_tps_task_pushed(struct ast_taskprocessor_listener *listener,
 		int was_empty)
 {
-	struct ast_threadpool *pool = listener->user_data;
+	struct ast_threadpool *pool = ast_taskprocessor_listener_get_user_data(listener);
 	struct task_pushed_data *tpd;
 	SCOPED_AO2LOCK(lock, pool);
 
@@ -588,7 +588,7 @@
  */
 static void threadpool_tps_emptied(struct ast_taskprocessor_listener *listener)
 {
-	struct ast_threadpool *pool = listener->user_data;
+	struct ast_threadpool *pool = ast_taskprocessor_listener_get_user_data(listener);
 	SCOPED_AO2LOCK(lock, pool);
 
 	if (pool->shutting_down) {
@@ -611,7 +611,7 @@
  */
 static void threadpool_tps_shutdown(struct ast_taskprocessor_listener *listener)
 {
-	struct ast_threadpool *pool = listener->user_data;
+	struct ast_threadpool *pool = ast_taskprocessor_listener_get_user_data(listener);
 
 	if (pool->listener && pool->listener->callbacks->shutdown) {
 		pool->listener->callbacks->shutdown(pool->listener);

Modified: team/mmichelson/threadpool/tests/test_taskprocessor.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/tests/test_taskprocessor.c?view=diff&rev=379125&r1=379124&r2=379125
==============================================================================
--- team/mmichelson/threadpool/tests/test_taskprocessor.c (original)
+++ team/mmichelson/threadpool/tests/test_taskprocessor.c Tue Jan 15 14:48:45 2013
@@ -283,7 +283,7 @@
  */
 static void test_task_pushed(struct ast_taskprocessor_listener *listener, int was_empty)
 {
-	struct test_listener_pvt *pvt = listener->user_data;
+	struct test_listener_pvt *pvt = ast_taskprocessor_listener_get_user_data(listener);
 	++pvt->num_pushed;
 	if (was_empty) {
 		++pvt->num_was_empty;
@@ -295,7 +295,7 @@
  */
 static void test_emptied(struct ast_taskprocessor_listener *listener)
 {
-	struct test_listener_pvt *pvt = listener->user_data;
+	struct test_listener_pvt *pvt = ast_taskprocessor_listener_get_user_data(listener);
 	++pvt->num_emptied;
 }
 
@@ -304,7 +304,7 @@
  */
 static void test_shutdown(struct ast_taskprocessor_listener *listener)
 {
-	struct test_listener_pvt *pvt = listener->user_data;
+	struct test_listener_pvt *pvt = ast_taskprocessor_listener_get_user_data(listener);
 	pvt->shutdown = 1;
 }
 




More information about the asterisk-commits mailing list