From 925442b3d91321d508fd225afb9fb3efe81ffa44 Mon Sep 17 00:00:00 2001 From: Michael Ploujnikov Date: Sat, 9 Jan 2010 21:36:20 -0500 Subject: [PATCH] begin adding a second list to store working threads --- src/backend/threadpool.c | 13 +++++++++---- src/backend/threadpool.h | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/backend/threadpool.c b/src/backend/threadpool.c index b423d3e5a..346a847d2 100644 --- a/src/backend/threadpool.c +++ b/src/backend/threadpool.c @@ -52,7 +52,8 @@ lumiera_threadpool_init(void) for (int i = 0; i < LUMIERA_THREADCLASS_COUNT; ++i) { - llist_init (&threadpool.pool[i].list); + llist_init (&threadpool.pool[i].working_list); + llist_init (&threadpool.pool[i].idle_list); threadpool.pool[i].working_thread_count = 0; threadpool.pool[i].idle_thread_count = 0; @@ -74,10 +75,14 @@ lumiera_threadpool_destroy(void) TRACE (threadpool, "destroying individual pool #%d", i); LUMIERA_CONDITION_SECTION (threadpool, &threadpool.pool[i].sync) { - REQUIRE (0 == threadpool.pool[i].working_thread_count, "%d threads are still running", threadpool.pool[i].working_thread_count); + REQUIRE (0 == threadpool.pool[i].working_thread_count && + 0 = llist_count (&threadpool.pool[i].working_list), + "%d(%d) threads are still running", + threadpool.pool[i].working_thread_count, + llist_count (&threadpool.pool[i].working_list)); // TODO need to have a stronger assertion that no threads are really running because they will not even be in the list - INFO (threadpool, "number of threads in the pool=%d", llist_count (&threadpool.pool[i].list)); - LLIST_WHILE_HEAD (&threadpool.pool[i].list, t) + INFO (threadpool, "working threads count=%d, idle threads count=%d", llist_count (&threadpool.pool[i].working_list), llist_count (&threadpool.pool[i].idle_list)); + LLIST_WHILE_HEAD (&threadpool.pool[i].idle_list, t) { lumiera_thread_delete ((LumieraThread)t); } diff --git a/src/backend/threadpool.h b/src/backend/threadpool.h index c2ec10785..b3fb5a18e 100644 --- a/src/backend/threadpool.h +++ b/src/backend/threadpool.h @@ -68,7 +68,8 @@ struct lumiera_threadpool_struct { struct { - llist list; + llist working_list; + llist working_idle; unsigned working_thread_count; unsigned idle_thread_count; pthread_attr_t pthread_attrs;