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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 15 13:44:28 CST 2013


Author: mmichelson
Date: Tue Jan 15 13:44:25 2013
New Revision: 379123

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379123
Log:
Make the initial size of the threadpool part of the options passed in.


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

Modified: team/mmichelson/threadpool/include/asterisk/threadpool.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/include/asterisk/threadpool.h?view=diff&rev=379123&r1=379122&r2=379123
==============================================================================
--- team/mmichelson/threadpool/include/asterisk/threadpool.h (original)
+++ team/mmichelson/threadpool/include/asterisk/threadpool.h Tue Jan 15 13:44:25 2013
@@ -102,6 +102,16 @@
 	 * to control threadpool growth yourself via your listener.
 	 */
 	int auto_increment;
+	/*!
+	 * \brief Number of threads the pool will start with
+	 *
+	 * When the threadpool is allocated, it will immediately size
+	 * itself to have this number of threads in it.
+	 *
+	 * Zero is a valid value if the threadpool should start
+	 * without any threads allocated.
+	 */
+	int initial_size;
 };
 
 /*!
@@ -126,13 +136,13 @@
  *
  * \param name The name for the threadpool
  * \param listener The listener the threadpool will notify of changes
- * \param initial_size The number of threads for the pool to start with
+ * \param options The behavioral options for this threadpool
  * \retval NULL Failed to create the threadpool
  * \retval non-NULL The newly-created threadpool
  */
 struct ast_threadpool *ast_threadpool_create(const char *name,
 		struct ast_threadpool_listener *listener,
-		int initial_size, const struct ast_threadpool_options *options);
+		const struct ast_threadpool_options *options);
 
 /*!
  * \brief Set the number of threads for the thread pool

Modified: team/mmichelson/threadpool/main/threadpool.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/main/threadpool.c?view=diff&rev=379123&r1=379122&r2=379123
==============================================================================
--- team/mmichelson/threadpool/main/threadpool.c (original)
+++ team/mmichelson/threadpool/main/threadpool.c Tue Jan 15 13:44:25 2013
@@ -828,7 +828,7 @@
 
 struct ast_threadpool *ast_threadpool_create(const char *name,
 		struct ast_threadpool_listener *listener,
-		int initial_size, const struct ast_threadpool_options *options)
+		const struct ast_threadpool_options *options)
 {
 	struct ast_taskprocessor *tps;
 	RAII_VAR(struct ast_taskprocessor_listener *, tps_listener, NULL, ao2_cleanup);
@@ -858,7 +858,7 @@
 		ao2_ref(listener, +1);
 		pool->listener = listener;
 	}
-	ast_threadpool_set_size(pool, initial_size);
+	ast_threadpool_set_size(pool, pool->options.initial_size);
 	ao2_ref(pool, +1);
 	return pool;
 }

Modified: team/mmichelson/threadpool/tests/test_threadpool.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/threadpool/tests/test_threadpool.c?view=diff&rev=379123&r1=379122&r2=379123
==============================================================================
--- team/mmichelson/threadpool/tests/test_threadpool.c (original)
+++ team/mmichelson/threadpool/tests/test_threadpool.c Tue Jan 15 13:44:25 2013
@@ -283,6 +283,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -306,7 +307,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -342,6 +343,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 3,
 	};
 
 	switch (cmd) {
@@ -367,7 +369,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 3, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -394,6 +396,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -418,7 +421,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -449,6 +452,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -473,7 +477,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -513,6 +517,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 2,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -537,7 +542,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -581,6 +586,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -605,7 +611,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -663,6 +669,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -687,7 +694,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -747,6 +754,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -771,7 +779,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -845,6 +853,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 3,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -871,7 +880,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -960,6 +969,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -986,7 +996,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -1128,6 +1138,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -1153,7 +1164,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}
@@ -1222,6 +1233,7 @@
 		.version = AST_THREADPOOL_OPTIONS_VERSION,
 		.idle_timeout = 0,
 		.auto_increment = 0,
+		.initial_size = 0,
 	};
 
 	switch (cmd) {
@@ -1249,7 +1261,7 @@
 		goto end;
 	}
 
-	pool = ast_threadpool_create(info->name, listener, 0, &options);
+	pool = ast_threadpool_create(info->name, listener, &options);
 	if (!pool) {
 		goto end;
 	}




More information about the asterisk-commits mailing list