Add threadpool options and accompanying test.

The only test added so far is an idle thread timeout
option. This will greatly aid threadpool users who wish
to maintain a threadpool by allowing for idle threads to
die out as necessary.

Test passes.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2012-12-10 06:13:09 +00:00
parent 5dd22df050
commit 64deed062a
3 changed files with 173 additions and 13 deletions

View File

@@ -82,6 +82,18 @@ struct ast_threadpool_listener {
void *private_data;
};
struct ast_threadpool_options {
#define AST_THREADPOOL_OPTIONS_VERSION 1
/*! Version of thradpool options in use */
int version;
/* !
* \brief Time limit in seconds for idle threads
*
* A time of 0 or less will mean an infinite timeout.
*/
int idle_timeout;
};
/*!
* \brief Allocate a threadpool listener
*
@@ -106,7 +118,8 @@ struct ast_threadpool_listener *ast_threadpool_listener_alloc(
* \retval NULL Failed to create the threadpool
* \retval non-NULL The newly-created threadpool
*/
struct ast_threadpool *ast_threadpool_create(struct ast_threadpool_listener *listener, int initial_size);
struct ast_threadpool *ast_threadpool_create(struct ast_threadpool_listener *listener,
int initial_size, const struct ast_threadpool_options *options);
/*!
* \brief Set the number of threads for the thread pool