• Home
  • Raw
  • Download

Lines Matching refs:pool

46 	struct thread_pool *pool;  member
51 static void thread_pool_thread_started(struct thread_pool *pool) in thread_pool_thread_started() argument
53 pthread_mutex_lock(&pool->thread_count_lock); in thread_pool_thread_started()
54 pool->thread_count++; in thread_pool_thread_started()
55 pthread_mutex_unlock(&pool->thread_count_lock); in thread_pool_thread_started()
58 static void thread_pool_thread_stopped(struct thread_pool *pool) in thread_pool_thread_stopped() argument
60 pthread_mutex_lock(&pool->thread_count_lock); in thread_pool_thread_stopped()
61 pool->thread_count--; in thread_pool_thread_stopped()
62 pthread_cond_signal(&pool->thread_count_cond); in thread_pool_thread_stopped()
63 pthread_mutex_unlock(&pool->thread_count_lock); in thread_pool_thread_stopped()
70 (*pdata->f)(pdata->pool, pdata->d); in thread_body()
72 thread_pool_thread_stopped(pdata->pool); in thread_body()
78 int thread_pool_add_thread(struct thread_pool *pool, in thread_pool_add_thread() argument
94 pdata->pool = pool; in thread_pool_add_thread()
106 thread_pool_thread_started(pool); in thread_pool_add_thread()
111 thread_pool_thread_stopped(pool); in thread_pool_add_thread()
125 struct thread_pool *pool; in thread_pool_new() local
127 pool = malloc(sizeof(*pool)); in thread_pool_new()
128 if (!pool) { in thread_pool_new()
133 pool->stop_fd = eventfd(0, EFD_NONBLOCK); in thread_pool_new()
134 if (pool->stop_fd == -1) { in thread_pool_new()
137 free(pool); in thread_pool_new()
142 pthread_mutex_init(&pool->thread_count_lock, NULL); in thread_pool_new()
143 pthread_cond_init(&pool->thread_count_cond, NULL); in thread_pool_new()
144 pool->thread_count = 0; in thread_pool_new()
146 return pool; in thread_pool_new()
149 int thread_pool_get_poll_fd(const struct thread_pool *pool) in thread_pool_get_poll_fd() argument
151 return pool->stop_fd; in thread_pool_get_poll_fd()
154 void thread_pool_stop(struct thread_pool *pool) in thread_pool_stop() argument
160 ret = write(pool->stop_fd, &e, sizeof(e)); in thread_pool_stop()
164 void thread_pool_stop_and_wait(struct thread_pool *pool) in thread_pool_stop_and_wait() argument
169 thread_pool_stop(pool); in thread_pool_stop_and_wait()
171 pthread_mutex_lock(&pool->thread_count_lock); in thread_pool_stop_and_wait()
172 while (pool->thread_count) in thread_pool_stop_and_wait()
173 pthread_cond_wait(&pool->thread_count_cond, in thread_pool_stop_and_wait()
174 &pool->thread_count_lock); in thread_pool_stop_and_wait()
175 pthread_mutex_unlock(&pool->thread_count_lock); in thread_pool_stop_and_wait()
178 ret = read(pool->stop_fd, &e, sizeof(e)); in thread_pool_stop_and_wait()
182 void thread_pool_destroy(struct thread_pool *pool) in thread_pool_destroy() argument
184 pthread_mutex_destroy(&pool->thread_count_lock); in thread_pool_destroy()
185 pthread_cond_destroy(&pool->thread_count_cond); in thread_pool_destroy()
187 close(pool->stop_fd); in thread_pool_destroy()
188 free(pool); in thread_pool_destroy()