Lines Matching refs:pool
44 struct threadpool *pool = data;
46 pthread_mutex_lock(&pool->m);
48 while (!pool->shutdown) {
52 while (!pool->workqueue && !pool->shutdown)
53 pthread_cond_wait(&pool->new_work, &pool->m);
55 if (pool->shutdown)
62 task = pool->workqueue;
63 pool->workqueue = task->next;
66 pthread_mutex_unlock(&pool->m);
68 pthread_mutex_lock(&pool->m);
73 pthread_mutex_unlock(&pool->m);
90 struct threadpool *pool = calloc(1, sizeof(*pool));
92 if (!pool)
95 pthread_mutex_init(&pool->m, NULL);
96 pthread_cond_init(&pool->new_work, NULL);
100 pool->wthread = NineSwapChain9_CreateThread(swapchain, wthreadpool_worker, pool);
101 if (!pool->wthread) {
103 pthread_create(&pool->pthread, NULL, threadpool_worker, pool);
105 return pool;
109 _mesa_threadpool_destroy(struct NineSwapChain9 *swapchain, struct threadpool *pool)
111 if (!pool)
114 pthread_mutex_lock(&pool->m);
115 pool->shutdown = TRUE;
116 pthread_cond_broadcast(&pool->new_work);
117 pthread_mutex_unlock(&pool->m);
119 if (pool->wthread) {
120 NineSwapChain9_WaitForThread(swapchain, pool->wthread);
122 pthread_join(pool->pthread, NULL);
125 pthread_cond_destroy(&pool->new_work);
126 pthread_mutex_destroy(&pool->m);
127 free(pool);
132 * thread pool.
142 _mesa_threadpool_queue_task(struct threadpool *pool,
147 if (!pool) {
163 pthread_mutex_lock(&pool->m);
165 if (!pool->workqueue) {
166 pool->workqueue = task;
168 previous = pool->workqueue;
174 pthread_cond_signal(&pool->new_work);
175 pthread_mutex_unlock(&pool->m);
184 _mesa_threadpool_wait_for_task(struct threadpool *pool,
189 if (!pool || !task)
192 pthread_mutex_lock(&pool->m);
194 pthread_cond_wait(&task->finish, &pool->m);
195 pthread_mutex_unlock(&pool->m);