41 const uint32_t queue_size) {
47#ifdef BUILD_ON_WINDOWS
58 for(uint32_t i = 0; i < thread_count; i++) {
73 if(
alloc(p, thread_count, queue_size) || !
utils(p) ||
74 !
start(p, thread_count)) {
82 if(
unlikely(p->shutdown || p->active == p->queue_size))
84 const uint32_t next = (p->tail + 1) % p->
queue_size;
86 p->queue[p->tail] = t;
95 const bool ret = add(p, fun,
arg);
106 for(uint32_t i = 0; i < p->
started; i++)
#define THREAD_RETURN(arg)
meta header (use this to include the whole library)
bool threadpool_add(threadpool_t *p, void(*fun)(void *), void *arg)
static ANN bool start(threadpool_t *p, const uint32_t thread_count)
static ANN gwtreturn_t threadpool_thread(void *data)
static ANN bool utils(threadpool_t *p)
static ANN bool alloc(threadpool_t *p, const uint32_t thread_count, const uint32_t queue_size)
ANN void free_threadpool(threadpool_t *p)
threadpool_t * new_threadpool(const uint32_t thread_count, const uint32_t queue_size)
static ANN bool gwt_create(gwtthread_t *thread, gwtreturn_t(*fun)(void *), void *arg)
static ANN void gwt_cond_end(gwtcond_t *cond)
static ANN int gwt_cond_ini(gwtcond_t *cond)
pthread_mutex_t gwtlock_t
static ANN int gwt_broadcast(gwtcond_t *cond)
static ANN int gwt_unlock(gwtlock_t *lock)
static ANN void gwt_join(gwtthread_t thread)
static ANN void gwt_lock_end(gwtlock_t *lock)
static ANN int gwt_lock_ini(gwtlock_t *lock)
static ANN int gwt_signal(gwtcond_t *cond)
static ANN void gwt_wait(gwtcond_t *cond, gwtlock_t *lock)
static ANN int gwt_lock(gwtlock_t *lock)