Skip to content

Commit

Permalink
workerpool: Properly wait for initialization of worker threads
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Bernard Berteaux committed Jun 26, 2024
1 parent aa5951a commit c16bba6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/workerpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ workerpool_t *workerpool_create(int nthreads)
return NULL;
}
}

// Wait for the worker threads to be ready
pthread_mutex_lock(&wp->mutex);
while (wp->end_count < wp->nthreads) {
pthread_cond_wait(&wp->endcond, &wp->mutex);
}
pthread_mutex_unlock(&wp->mutex);
}

return wp;
Expand Down

0 comments on commit c16bba6

Please sign in to comment.