Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use pthread_mutex_t

Can someone please explain in what scenario's it would be beneficial to use std::mutex vs pthread_mutex_t. I dont understand why we would ever use pthread_mutex_t. Thanks

like image 313
Jonathon Hill Avatar asked May 09 '16 08:05

Jonathon Hill


1 Answers

The pthread_mutex_t is a POSIX solution (available for linux and other UNIX systems) that existed before c++11 introduced synchronisation primitives into the c++ library. You should use std::mutex now, amongst other things it is more cross-platform (can be used under Windows also).

like image 154
Smeeheey Avatar answered Jan 04 '23 05:01

Smeeheey