Lines Matching refs:pool

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