29 #define _GNU_SOURCE // Possible fix for 16.04
74 pthread_mutex_lock(&wp->
mutex);
77 pthread_cond_broadcast(&wp->
endcond);
83 pthread_mutex_unlock(&wp->
mutex);
108 pthread_mutex_init(&wp->
mutex, NULL);
110 pthread_cond_init(&wp->
endcond, NULL);
112 for (
int i = 0; i < nthreads; i++) {
115 debug_print(
"Insufficient system resources to create workerpool threads\n");
122 pthread_mutex_lock(&wp->
mutex);
126 pthread_mutex_unlock(&wp->
mutex);
139 for (
int i = 0; i < wp->
nthreads; i++)
142 pthread_mutex_lock(&wp->
mutex);
145 pthread_mutex_unlock(&wp->
mutex);
147 for (
int i = 0; i < wp->
nthreads; i++)
148 pthread_join(wp->
threads[i], NULL);
150 pthread_mutex_destroy(&wp->
mutex);
152 pthread_cond_destroy(&wp->
endcond);
172 pthread_mutex_lock(&wp->
mutex);
174 pthread_mutex_unlock(&wp->
mutex);
195 pthread_mutex_lock(&wp->
mutex);
207 pthread_mutex_unlock(&wp->
mutex);
220 GetSystemInfo(&sysinfo);
221 return sysinfo.dwNumberOfProcessors;
223 return sysconf (_SC_NPROCESSORS_ONLN);