29 #define _GNU_SOURCE // Possible fix for 16.04 74 pthread_mutex_lock(&wp->
mutex);
78 pthread_cond_broadcast(&wp->
endcond);
87 pthread_mutex_unlock(&wp->
mutex);
103 assert(nthreads > 0);
112 pthread_mutex_init(&wp->
mutex, NULL);
114 pthread_cond_init(&wp->
endcond, NULL);
116 for (
int i = 0; i <
nthreads; i++) {
119 debug_print(
"Insufficient system resources to create workerpool threads\n");
136 for (
int i = 0; i < wp->
nthreads; i++)
139 pthread_mutex_lock(&wp->
mutex);
141 pthread_mutex_unlock(&wp->
mutex);
143 for (
int i = 0; i < wp->
nthreads; i++)
144 pthread_join(wp->
threads[i], NULL);
146 pthread_mutex_destroy(&wp->
mutex);
148 pthread_cond_destroy(&wp->
endcond);
187 pthread_mutex_lock(&wp->
mutex);
195 pthread_mutex_unlock(&wp->
mutex);
210 GetSystemInfo(&sysinfo);
211 return sysinfo.dwNumberOfProcessors;
213 return sysconf (_SC_NPROCESSORS_ONLN);
void workerpool_run_single(workerpool_t *wp)
void workerpool_add_task(workerpool_t *wp, void(*f)(void *p), void *p)
static void zarray_get_volatile(const zarray_t *za, int idx, void *p)
void workerpool_destroy(workerpool_t *wp)
#define debug_print(fmt,...)
static int zarray_size(const zarray_t *za)
workerpool_t * workerpool_create(int nthreads)
static void zarray_destroy(zarray_t *za)
static zarray_t * zarray_create(size_t el_sz)
void workerpool_run(workerpool_t *wp)
void * worker_thread(void *p)
int workerpool_get_nthreads(workerpool_t *wp)
static void zarray_clear(zarray_t *za)
int workerpool_get_nprocs()
static void zarray_add(zarray_t *za, const void *p)