diff --git a/src/backend/threadpool.c b/src/backend/threadpool.c index 5960c890f..1a48967dd 100644 --- a/src/backend/threadpool.c +++ b/src/backend/threadpool.c @@ -112,9 +112,15 @@ lumiera_threadpool_release_thread(LumieraThread thread) { REQUIRE (thread, "invalid thread given"); REQUIRE (thread->kind < LUMIERA_THREADCLASS_COUNT, "thread belongs to an unknown pool kind: %d", thread->kind); - REQUIRE (llist_is_single(&thread->node), "thread already belongs to some list"); - llist_insert_head(&threadpool.kind[thread->kind].pool, &thread->node); - REQUIRE (!llist_is_empty (&threadpool.kind[thread->kind].pool), "thread pool is still empty after insertion"); + REQUIRE (&threadpool.kind[thread->kind].lock, "invalid threadpool lock"); + + // TOOD: currently, locking produces memory leaks + // LUMIERA_MUTEX_SECTION (threadpool, &threadpool.kind[thread->kind].lock) + // { + //REQUIRE (llist_is_single(&thread->node), "thread already belongs to some list"); + llist_insert_head(&threadpool.kind[thread->kind].pool, &thread->node); + // REQUIRE (!llist_is_empty (&threadpool.kind[thread->kind].pool), "thread pool is still empty after insertion"); + // } } /* diff --git a/src/backend/threads.c b/src/backend/threads.c index 4471fb444..52125fcef 100644 --- a/src/backend/threads.c +++ b/src/backend/threads.c @@ -170,6 +170,7 @@ lumiera_thread_new (enum lumiera_thread_class kind, //REQUIRE (finished, "invalid finished flag passed"); LumieraThread self = lumiera_malloc (sizeof (*self)); + ECHO ("allocated thread struct of size %zd", sizeof (*self)); llist_init(&self->node); self->finished = finished; self->kind = kind; @@ -193,7 +194,6 @@ lumiera_thread_new (enum lumiera_thread_class kind, LumieraThread lumiera_thread_destroy (LumieraThread self) { - ECHO ("destroying thread"); REQUIRE (self, "trying to destroy an invalid thread"); // TODO: stop the pthread diff --git a/tests/30backend-threadpool.tests b/tests/30backend-threadpool.tests index a23ff38ea..44392f279 100644 --- a/tests/30backend-threadpool.tests +++ b/tests/30backend-threadpool.tests @@ -8,17 +8,19 @@ PLANNED "cancel" TEST "Acquire/Release test" basic-acquire-release <