Prefer the pthread_barrier implementation over uv_barrier
Prefer the pthread_barrier implementation on platforms where it is available over uv_barrier implementation. This also solves the problem with thread sanitizer builds on macOS that doesn't have pthread barrier.