libresman
diff src/threadpool.c @ 10:4d18498a0078
moved the resource manager a bit further
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 05 Feb 2014 02:01:49 +0200 |
parents | 03f3de659c32 |
children | bebc065a941f |
line diff
1.1 --- a/src/threadpool.c Tue Feb 04 05:42:31 2014 +0200 1.2 +++ b/src/threadpool.c Wed Feb 05 02:01:49 2014 +0200 1.3 @@ -69,6 +69,27 @@ 1.4 pthread_cond_destroy(&tpool->work_cond); 1.5 } 1.6 1.7 +struct thread_pool *tpool_create(int num_threads) 1.8 +{ 1.9 + struct thread_pool *tpool = malloc(sizeof *tpool); 1.10 + if(!tpool) { 1.11 + return 0; 1.12 + } 1.13 + if(tpool_init(tpool, num_threads) == -1) { 1.14 + free(tpool); 1.15 + return 0; 1.16 + } 1.17 + return tpool; 1.18 +} 1.19 + 1.20 +void tpool_free(struct thread_pool *tpool) 1.21 +{ 1.22 + if(tpool) { 1.23 + tpool_destroy(tpool); 1.24 + free(tpool); 1.25 + } 1.26 +} 1.27 + 1.28 void tpool_set_work_func(struct thread_pool *tpool, tpool_work_func func, void *cls) 1.29 { 1.30 tpool->work_func = func;