- pthread_mutex_lock(&shared.mutex);
- while(shared.count > 0)
- pthread_cond_wait(&shared.cond, &shared.mutex);
-
- pthread_mutex_unlock(&shared.mutex);
- pthread_mutex_destroy(&shared.mutex);
- pthread_cond_destroy(&shared.cond);
+ dispatch_group_wait(shared.group, DISPATCH_TIME_FOREVER);
+ dispatch_release(shared.group);