--- a/ui/common/threadpool.c Thu Dec 04 19:04:08 2025 +0100 +++ b/ui/common/threadpool.c Sat Dec 06 14:12:11 2025 +0100 @@ -54,10 +54,11 @@ } int threadpool_start(UiThreadpool *pool) { + pool->nthreads = pool->min_threads; + pool->threads = calloc(pool->max_threads, sizeof(pthread_t)); /* create pool threads */ - for(int i=0;i<pool->min_threads;i++) { - pthread_t t; - if (pthread_create(&t, NULL, threadpool_func, pool) != 0) { + for(int i=0;i<pool->nthreads;i++) { + if (pthread_create(&pool->threads[i], NULL, threadpool_func, pool) != 0) { fprintf(stderr, "uic: threadpool_start: pthread_create failed: %s", strerror(errno)); return 1; } @@ -65,6 +66,16 @@ return 0; } +int threadpool_join(UiThreadpool *pool) { + int err = 0; + for(int i=0;i<pool->nthreads;i++) { + if(pthread_join(pool->threads[i], NULL)) { + err = 1; + } + } + return err; +} + void* threadpool_func(void *data) { UiThreadpool *pool = (UiThreadpool*)data;