pool 40 src/libsir/include/sir/threadpool.h bool _sir_threadpool_create(sir_threadpool** pool, size_t num_threads); pool 41 src/libsir/include/sir/threadpool.h bool _sir_threadpool_add_job(sir_threadpool* pool, sir_threadpool_job* job); pool 42 src/libsir/include/sir/threadpool.h bool _sir_threadpool_destroy(sir_threadpool** pool); pool 45 src/libsir/src/sirthreadpool.c bool _sir_threadpool_create(sir_threadpool** pool, size_t num_threads) { pool 46 src/libsir/src/sirthreadpool.c if (!pool || !num_threads || num_threads > SIR_THREADPOOL_MAX_THREADS) pool 49 src/libsir/src/sirthreadpool.c *pool = calloc(1, sizeof(sir_threadpool)); pool 50 src/libsir/src/sirthreadpool.c if (!*pool) pool 53 src/libsir/src/sirthreadpool.c (*pool)->threads = calloc(num_threads, sizeof(sir_thread)); pool 54 src/libsir/src/sirthreadpool.c if (!(*pool)->threads) { pool 56 src/libsir/src/sirthreadpool.c _sir_safefree(pool); pool 60 src/libsir/src/sirthreadpool.c (*pool)->num_threads = num_threads; pool 62 src/libsir/src/sirthreadpool.c if (!_sir_queue_create(&(*pool)->jobs) || !_sir_condcreate(&(*pool)->cond) || pool 63 src/libsir/src/sirthreadpool.c !_sir_mutexcreate(&(*pool)->mutex)) { pool 64 src/libsir/src/sirthreadpool.c bool destroy = _sir_threadpool_destroy(pool); pool 73 src/libsir/src/sirthreadpool.c bool destroy = _sir_threadpool_destroy(pool); pool 83 src/libsir/src/sirthreadpool.c op = pthread_create(&(*pool)->threads[n], &attr, &thread_pool_proc, *pool); pool 85 src/libsir/src/sirthreadpool.c (*pool)->threads[n] = 0; pool 91 src/libsir/src/sirthreadpool.c (*pool)->threads[n] = (HANDLE)_beginthreadex(NULL, 0, &thread_pool_proc, pool 92 src/libsir/src/sirthreadpool.c *pool, 0, NULL); pool 93 src/libsir/src/sirthreadpool.c if (!(*pool)->threads[n]) { pool 107 src/libsir/src/sirthreadpool.c bool destroy = _sir_threadpool_destroy(pool); pool 112 src/libsir/src/sirthreadpool.c return !!*pool; pool 115 src/libsir/src/sirthreadpool.c bool _sir_threadpool_add_job(sir_threadpool* pool, sir_threadpool_job* job) { pool 118 src/libsir/src/sirthreadpool.c if (pool && pool->jobs && job && job->fn && job->data) { pool 119 src/libsir/src/sirthreadpool.c bool locked = _sir_mutexlock(&pool->mutex); pool 123 src/libsir/src/sirthreadpool.c if (_sir_queue_push(pool->jobs, job)) { pool 124 src/libsir/src/sirthreadpool.c retval = _sir_condbroadcast(&pool->cond); pool 125 src/libsir/src/sirthreadpool.c _sir_selflog("added job; new size: %zu", _sir_queue_size(pool->jobs)); pool 128 src/libsir/src/sirthreadpool.c bool unlocked = _sir_mutexunlock(&pool->mutex); pool 136 src/libsir/src/sirthreadpool.c bool _sir_threadpool_destroy(sir_threadpool** pool) { pool 137 src/libsir/src/sirthreadpool.c if (!pool || !*pool) pool 140 src/libsir/src/sirthreadpool.c bool locked = _sir_mutexlock(&(*pool)->mutex); pool 145 src/libsir/src/sirthreadpool.c (*pool)->cancel = true; pool 147 src/libsir/src/sirthreadpool.c bool bcast = _sir_condbroadcast(&(*pool)->cond); pool 150 src/libsir/src/sirthreadpool.c bool unlock = _sir_mutexunlock(&(*pool)->mutex); pool 155 src/libsir/src/sirthreadpool.c for (size_t n = 0; n < (*pool)->num_threads; n++) { pool 156 src/libsir/src/sirthreadpool.c SIR_ASSERT(0 != (*pool)->threads[n]); pool 157 src/libsir/src/sirthreadpool.c if (0 == (*pool)->threads[n]) pool 159 src/libsir/src/sirthreadpool.c _sir_selflog("joining thread %zu of %zu...", n + 1, (*pool)->num_threads); pool 161 src/libsir/src/sirthreadpool.c int join = pthread_join((*pool)->threads[n], NULL); pool 165 src/libsir/src/sirthreadpool.c DWORD join = WaitForSingleObject((*pool)->threads[n], INFINITE); pool 171 src/libsir/src/sirthreadpool.c _sir_eqland(destroy, _sir_queue_destroy(&(*pool)->jobs)); pool 174 src/libsir/src/sirthreadpool.c _sir_eqland(destroy, _sir_conddestroy(&(*pool)->cond)); pool 177 src/libsir/src/sirthreadpool.c _sir_eqland(destroy, _sir_mutexdestroy(&(*pool)->mutex)); pool 180 src/libsir/src/sirthreadpool.c _sir_safefree(&(*pool)->threads); pool 181 src/libsir/src/sirthreadpool.c _sir_safefree(pool); pool 192 src/libsir/src/sirthreadpool.c sir_threadpool* pool = (sir_threadpool*)arg; pool 194 src/libsir/src/sirthreadpool.c bool locked = _sir_mutexlock(&pool->mutex); pool 197 src/libsir/src/sirthreadpool.c while (_sir_queue_isempty(pool->jobs) && !pool->cancel) { pool 205 src/libsir/src/sirthreadpool.c (void)_sir_condwait_timeout(&pool->cond, &pool->mutex, &wait); pool 208 src/libsir/src/sirthreadpool.c if (!pool->cancel) { pool 210 src/libsir/src/sirthreadpool.c bool job_popped = _sir_queue_pop(pool->jobs, (void**)&job); pool 212 src/libsir/src/sirthreadpool.c bool unlocked = _sir_mutexunlock(&pool->mutex); pool 223 src/libsir/src/sirthreadpool.c bool unlocked = _sir_mutexunlock(&pool->mutex);