Lines Matching refs:pool

192   mps_thread_pool * pool = thread->pool;  in mps_thread_mainloop()  local
197 pthread_mutex_lock (&pool->work_completed_mutex); in mps_thread_mainloop()
198 pthread_mutex_lock (&pool->queue_changed_mutex); in mps_thread_mainloop()
200 if (pool->queue->first != NULL) in mps_thread_mainloop()
202 mps_thread_pool_queue_item * item = pool->queue->first; in mps_thread_mainloop()
206 pool->busy_counter++; in mps_thread_mainloop()
211 pool->queue->first = item->next; in mps_thread_mainloop()
213 pool->queue->last = item; in mps_thread_mainloop()
215 pthread_mutex_unlock (&pool->queue_changed_mutex); in mps_thread_mainloop()
216 pthread_mutex_unlock (&pool->work_completed_mutex); in mps_thread_mainloop()
226 pool->busy_counter--; in mps_thread_mainloop()
229 pthread_cond_signal (&pool->work_completed_cond); in mps_thread_mainloop()
230 pthread_mutex_unlock (&pool->work_completed_mutex); in mps_thread_mainloop()
234 pthread_mutex_unlock (&pool->queue_changed_mutex); in mps_thread_mainloop()
238 pthread_cond_wait (&pool->queue_changed, &pool->queue_changed_mutex); in mps_thread_mainloop()
239 pthread_mutex_unlock (&pool->queue_changed_mutex); in mps_thread_mainloop()
259 void mps_thread_pool_set_concurrency_limit (mps_context * s, mps_thread_pool * pool, in mps_thread_pool_set_concurrency_limit() argument
262 if (pool == NULL) in mps_thread_pool_set_concurrency_limit()
263 pool = s->pool; in mps_thread_pool_set_concurrency_limit()
268 if (concurrency_limit < pool->concurrency_limit) in mps_thread_pool_set_concurrency_limit()
270 mps_thread * old_first = pool->first; in mps_thread_pool_set_concurrency_limit()
274 …for (thread = pool->first; i < (pool->concurrency_limit - concurrency_limit); thread = thread->nex… in mps_thread_pool_set_concurrency_limit()
277 pool->first = thread; in mps_thread_pool_set_concurrency_limit()
278 pool->n = concurrency_limit; in mps_thread_pool_set_concurrency_limit()
281 for (thread = old_first; i < (pool->concurrency_limit - concurrency_limit); i++) in mps_thread_pool_set_concurrency_limit()
291 for (i = 0; i < concurrency_limit - pool->concurrency_limit; i++) in mps_thread_pool_set_concurrency_limit()
292 mps_thread_pool_insert_new_thread (s, s->pool); in mps_thread_pool_set_concurrency_limit()
295 pool->concurrency_limit = concurrency_limit; in mps_thread_pool_set_concurrency_limit()
299 mps_thread_pool_assign (mps_context * s, mps_thread_pool * pool, in mps_thread_pool_assign() argument
302 if (!pool) in mps_thread_pool_assign()
303 pool = s->pool; in mps_thread_pool_assign()
305 if (pool->n == 1 && !pool->strict_async) in mps_thread_pool_assign()
312 pthread_mutex_lock (&pool->queue_changed_mutex); in mps_thread_pool_assign()
319 if (pool->queue->first == NULL) in mps_thread_pool_assign()
321 pool->queue->first = pool->queue->last = item; in mps_thread_pool_assign()
326 pool->queue->last->next = item; in mps_thread_pool_assign()
327 pool->queue->last = item; in mps_thread_pool_assign()
331 pthread_cond_signal (&pool->queue_changed); in mps_thread_pool_assign()
332 pthread_mutex_unlock (&pool->queue_changed_mutex); in mps_thread_pool_assign()
339 mps_thread_pool_wait (mps_context * s, mps_thread_pool * pool) in mps_thread_pool_wait() argument
341 pthread_mutex_lock (&pool->work_completed_mutex); in mps_thread_pool_wait()
345 if (pool->busy_counter == 0 && pool->queue->first == NULL) in mps_thread_pool_wait()
347 pthread_mutex_unlock (&pool->work_completed_mutex); in mps_thread_pool_wait()
352 pthread_cond_wait (&pool->work_completed_cond, &pool->work_completed_mutex); in mps_thread_pool_wait()
361 mps_thread_new (mps_context * s, mps_thread_pool * pool) in mps_thread_new() argument
363 if (!pool) in mps_thread_new()
364 pool = s->pool; in mps_thread_new()
375 thread->pool = pool; in mps_thread_new()
393 pthread_mutex_lock (&thread->pool->queue_changed_mutex); in mps_thread_free()
397 pthread_cond_broadcast (&thread->pool->queue_changed); in mps_thread_free()
398 pthread_mutex_unlock (&thread->pool->queue_changed_mutex); in mps_thread_free()
410 mps_thread_pool_insert_new_thread (mps_context * s, mps_thread_pool * pool) in mps_thread_pool_insert_new_thread() argument
412 if (!pool) in mps_thread_pool_insert_new_thread()
413 pool = s->pool; in mps_thread_pool_insert_new_thread()
415 mps_thread * thread = mps_thread_new (s, pool); in mps_thread_pool_insert_new_thread()
417 thread->next = pool->first; in mps_thread_pool_insert_new_thread()
418 pool->first = thread; in mps_thread_pool_insert_new_thread()
419 pool->n++; in mps_thread_pool_insert_new_thread()
448 mps_thread_pool_set_strict_async (mps_thread_pool * pool, mps_boolean strict_async) in mps_thread_pool_set_strict_async() argument
450 pool->strict_async = strict_async; in mps_thread_pool_set_strict_async()
460 mps_thread_pool * pool = mps_new (mps_thread_pool); in mps_thread_pool_new() local
467 pool->n = 0; in mps_thread_pool_new()
468 pool->first = NULL; in mps_thread_pool_new()
470 pool->queue = mps_new (mps_thread_pool_queue); in mps_thread_pool_new()
471 pool->queue->first = pool->queue->last = NULL; in mps_thread_pool_new()
473 pthread_mutex_init (&pool->queue_changed_mutex, NULL); in mps_thread_pool_new()
474 pthread_cond_init (&pool->queue_changed, NULL); in mps_thread_pool_new()
476 pthread_mutex_init (&pool->work_completed_mutex, NULL); in mps_thread_pool_new()
477 pthread_cond_init (&pool->work_completed_cond, NULL); in mps_thread_pool_new()
479 pool->busy_counter = 0; in mps_thread_pool_new()
480 pool->strict_async = false; in mps_thread_pool_new()
483 mps_thread_pool_insert_new_thread (s, pool); in mps_thread_pool_new()
485 pool->concurrency_limit = threads; in mps_thread_pool_new()
487 mps_thread_pool_wait (s, pool); in mps_thread_pool_new()
489 return pool; in mps_thread_pool_new()
497 mps_thread_pool_free (mps_context * s, mps_thread_pool * pool) in mps_thread_pool_free() argument
499 if (!pool) in mps_thread_pool_free()
500 pool = s->pool; in mps_thread_pool_free()
502 mps_thread * thread = pool->first; in mps_thread_pool_free()
505 mps_thread_pool_wait (s, pool); in mps_thread_pool_free()
514 free (pool->queue); in mps_thread_pool_free()
515 free (pool); in mps_thread_pool_free()
518 int mps_thread_get_id (mps_context * s, mps_thread_pool * pool) in mps_thread_get_id() argument
523 mps_thread * thread = pool->first; in mps_thread_get_id()