Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Although there are owning mutexes for C++ the C++ standard library does not provide such a thing. So the std::mutex used in the example is not an owning mutex and that example works and does what was described.

One reason not to provide the owning mutex in C++ is that it isn't able to deliver similar guarantees to Rust because its type system isn't strong enough. Rust won't let you accidentally keep a reference to the protected object after unlocking, C++ will for example.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: