
Since the "lock" et "mutex" types provide ways to lock/unlock access to resources, why are not these types defined under the same name ? Are the concepts they implements much more different than I think ?
As Markus mentioned, lock objects are just raii-style helpers for exception safe locking. As for multiple mutex types, they stand for different approaches to the resource sharing problem. If you just want to always lock your resource exclusively, use simple "mutex" class; if you prefer to allow simultaneous shared access as long as there're readers only, use shared_mutex; and if you'd like to be able to lock the mutex several times from the same thread, use recursive_mutex (like this: { mutex_.lock(); mutex_.lock(); /*....*/ mutex_.unlock(); mutex_.unlock(); }