Lines Matching refs:pool

57     struct toku_thread_pool *pool;  member
80 static void toku_thread_pool_lock(struct toku_thread_pool *pool);
81 static void toku_thread_pool_unlock(struct toku_thread_pool *pool);
84 toku_thread_create(struct toku_thread_pool *pool, struct toku_thread **toku_thread_return) { in toku_thread_create() argument
91 thread->pool = pool; in toku_thread_create()
110 toku_thread_pool_lock(thread->pool); in toku_thread_run()
114 toku_thread_pool_unlock(thread->pool); in toku_thread_run()
122 struct toku_thread_pool *pool = thread->pool; in toku_thread_destroy() local
123 toku_thread_pool_lock(pool); in toku_thread_destroy()
125 toku_thread_pool_unlock(pool); in toku_thread_destroy()
139 struct toku_thread_pool *pool = thread->pool; in toku_thread_run_internal() local
140 toku_thread_pool_lock(pool); in toku_thread_run_internal()
142 toku_cond_signal(&pool->wait_free); in toku_thread_run_internal()
148 toku_cond_wait(&thread->wait, &pool->lock); in toku_thread_run_internal()
150 toku_thread_pool_unlock(pool); in toku_thread_run_internal()
155 toku_thread_pool_lock(pool); in toku_thread_run_internal()
157 toku_list_push(&pool->free_threads, &thread->free_link); in toku_thread_run_internal()
165 struct toku_thread_pool *CALLOC(pool); in toku_thread_pool_create()
166 if (pool == nullptr) { in toku_thread_pool_create()
169 toku_mutex_init(*tpool_lock_mutex_key, &pool->lock, nullptr); in toku_thread_pool_create()
170 toku_list_init(&pool->free_threads); in toku_thread_pool_create()
171 toku_list_init(&pool->all_threads); in toku_thread_pool_create()
172 toku_cond_init(*tp_pool_wait_free_key, &pool->wait_free, nullptr); in toku_thread_pool_create()
173 pool->cur_threads = 0; in toku_thread_pool_create()
174 pool->max_threads = max_threads; in toku_thread_pool_create()
175 *pool_return = pool; in toku_thread_pool_create()
182 toku_thread_pool_lock(struct toku_thread_pool *pool) { in toku_thread_pool_lock() argument
183 toku_mutex_lock(&pool->lock); in toku_thread_pool_lock()
187 toku_thread_pool_unlock(struct toku_thread_pool *pool) { in toku_thread_pool_unlock() argument
188 toku_mutex_unlock(&pool->lock); in toku_thread_pool_unlock()
193 struct toku_thread_pool *pool = *poolptr; in toku_thread_pool_destroy() local
197 toku_thread_pool_lock(pool); in toku_thread_pool_destroy()
199 for (list = pool->all_threads.next; list != &pool->all_threads; list = list->next) { in toku_thread_pool_destroy()
203 toku_thread_pool_unlock(pool); in toku_thread_pool_destroy()
206 while (!toku_list_empty(&pool->all_threads)) { in toku_thread_pool_destroy()
207 list = toku_list_pop_head(&pool->all_threads); in toku_thread_pool_destroy()
210 pool->cur_threads -= 1; in toku_thread_pool_destroy()
213 invariant(pool->cur_threads == 0); in toku_thread_pool_destroy()
216 toku_cond_destroy(&pool->wait_free); in toku_thread_pool_destroy()
217 toku_mutex_destroy(&pool->lock); in toku_thread_pool_destroy()
219 toku_free(pool); in toku_thread_pool_destroy()
223 toku_thread_pool_add(struct toku_thread_pool *pool) { in toku_thread_pool_add() argument
225 int r = toku_thread_create(pool, &thread); in toku_thread_pool_add()
227 pool->cur_threads += 1; in toku_thread_pool_add()
228 toku_list_push(&pool->all_threads, &thread->all_link); in toku_thread_pool_add()
229 toku_list_push(&pool->free_threads, &thread->free_link); in toku_thread_pool_add()
230 toku_cond_signal(&pool->wait_free); in toku_thread_pool_add()
237 toku_thread_pool_get_one(struct toku_thread_pool *pool, int dowait, struct toku_thread **toku_threa… in toku_thread_pool_get_one() argument
239 toku_thread_pool_lock(pool); in toku_thread_pool_get_one()
240 pool->gets++; in toku_thread_pool_get_one()
242 if (!toku_list_empty(&pool->free_threads)) in toku_thread_pool_get_one()
244 if (pool->max_threads == 0 || pool->cur_threads < pool->max_threads) in toku_thread_pool_get_one()
245 (void) toku_thread_pool_add(pool); in toku_thread_pool_get_one()
246 if (toku_list_empty(&pool->free_threads) && !dowait) { in toku_thread_pool_get_one()
250 pool->get_blocks++; in toku_thread_pool_get_one()
251 toku_cond_wait(&pool->wait_free, &pool->lock); in toku_thread_pool_get_one()
254 struct toku_list *list = toku_list_pop_head(&pool->free_threads); in toku_thread_pool_get_one()
259 toku_thread_pool_unlock(pool); in toku_thread_pool_get_one()
264 toku_thread_pool_get(struct toku_thread_pool *pool, int dowait, int *nthreads, struct toku_thread *… in toku_thread_pool_get() argument
269 r = toku_thread_pool_get_one(pool, dowait, &toku_thread_return[i]); in toku_thread_pool_get()
278 toku_thread_pool_run(struct toku_thread_pool *pool, int dowait, int *nthreads, void *(*f)(void *arg… in toku_thread_pool_run() argument
281 int r = toku_thread_pool_get(pool, dowait, nthreads, tids); in toku_thread_pool_run()
291 toku_thread_pool_print(struct toku_thread_pool *pool, FILE *out) { in toku_thread_pool_print() argument
292 …"%s:%d %p %llu %llu\n", __FILE__, __LINE__, pool, (long long unsigned) pool->gets, (long long unsi… in toku_thread_pool_print()
296 toku_thread_pool_get_current_threads(struct toku_thread_pool *pool) { in toku_thread_pool_get_current_threads() argument
297 return pool->cur_threads; in toku_thread_pool_get_current_threads()