summaryrefslogtreecommitdiff
path: root/main/threadpool.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2013-01-15 19:36:33 +0000
committerMark Michelson <mmichelson@digium.com>2013-01-15 19:36:33 +0000
commitedc2e4dac0a6d532957fd27b6b784232cf2ae55c (patch)
treec85008d0d91b41d83d995bfea5eb852d5d5dd202 /main/threadpool.c
parent65c7d6e2c3d4fc3a161a31ff1e89d20256926fb1 (diff)
Remove threadpool listener alloc and destroy callbacks.
This replaces the destroy callback with a shutdown callback instead. git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379122 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/threadpool.c')
-rw-r--r--main/threadpool.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/main/threadpool.c b/main/threadpool.c
index db38daa8f..f37095364 100644
--- a/main/threadpool.c
+++ b/main/threadpool.c
@@ -613,6 +613,7 @@ static void threadpool_tps_shutdown(struct ast_taskprocessor_listener *listener)
{
struct ast_threadpool *pool = listener->user_data;
+ pool->listener->callbacks->shutdown(pool->listener);
ao2_cleanup(pool->active_threads);
ao2_cleanup(pool->idle_threads);
ao2_cleanup(pool->zombie_threads);
@@ -808,26 +809,15 @@ void ast_threadpool_set_size(struct ast_threadpool *pool, unsigned int size)
ast_taskprocessor_push(pool->control_tps, queued_set_size, ssd);
}
-static void listener_destructor(void *obj)
-{
- struct ast_threadpool_listener *listener = obj;
-
- listener->callbacks->destroy(listener->private_data);
-}
-
struct ast_threadpool_listener *ast_threadpool_listener_alloc(
- const struct ast_threadpool_listener_callbacks *callbacks)
+ const struct ast_threadpool_listener_callbacks *callbacks, void *user_data)
{
- struct ast_threadpool_listener *listener = ao2_alloc(sizeof(*listener), listener_destructor);
+ struct ast_threadpool_listener *listener = ao2_alloc(sizeof(*listener), NULL);
if (!listener) {
return NULL;
}
listener->callbacks = callbacks;
- listener->private_data = listener->callbacks->alloc(listener);
- if (!listener->private_data) {
- ao2_ref(listener, -1);
- return NULL;
- }
+ listener->user_data = user_data;
return listener;
}