What are the advantages of other mutex wrapper libraries over std::mutex?
std::mutex
, std::thread
and other elements of the threading library are only available C++11. boost::mutex
et al predate C++11. So the advantage is that you can use them if you don't have C++11 support.
While juanchopanza noted the most direct answer to the question (+1), one thing which std::mutex
introduces over the types they wrap is use of exceptions. For most people/environments/needs, that would be considered a good thing. In some cases, you may not want exception dependence. In that case/environment, the std::mutex
interfaces may not be an option or desirable.
Some wrappers, like TBB and PPL, offer far more functionality than the Standard libraries.
- Using pthreads/CreateThread yourself = writing your own
malloc
. - Using
std::thread
=malloc
/free
. - Using TBB/PPL =
std::vector
/std::unique_ptr
.