Answer by Casey for GCC C++11 Condition Variable Wait Internals
The function (which I believe to be std::condition_variable_any<_Lock>::wait) is avoiding deadlock by establishing a lock ordering invariant that __lock must be locked before acquiring _M_mutex....
View ArticleAnswer by Michael Anderson for GCC C++11 Condition Variable Wait Internals
It looks like it is to reorder the destruction of the __lock and __my_lock variables.The calls should look like this:construct __my_lock // locks _M_mutexconstruct __unlock // unlocks __lockconstruct...
View ArticleAnswer by Howard Hinnant for GCC C++11 Condition Variable Wait Internals
This does not look like condition_variable code. It looks like condition_variable_any code. The latter has a templated wait function. The former does not.N2406 may shed light on what you are seeing. In...
View ArticleGCC C++11 Condition Variable Wait Internals
I'm hunting down a bug we have with some messy thread/condition variable classes being updated to use C++11 threads. During the course of the hunt, I've come across the following in the GCC codebase:...
View Article