If I have an initialised pthread_barrier_t, when is it safe to destroy it? Is the following example safe?
pthread_barrier_t barrier;
...
int rc = pthread_barrier_wait(b);
if (rc != PTHREAD_BARRIER_SERIAL_THREAD && rc != 0){
perror("pthread_barrier_wait");
exit(1);
}
if (id == 0){
if(pthread_barrier_destroy(&(threads[t_root].info.tmp_barrier))){
perror("pthread_barrier_destroy");
exit(1);
}
}