[v3] mutex vs. cstdatomic

Peter Dimov pdimov@mmltd.net
Sat Dec 13 18:20:00 GMT 2008


Chris Fairles:
> Keep note that <mutex>'s unique_lock<> should be using atomic_bool for
> its internal _M_owns variable so <mutex> will eventually need to
> include <cstdatomic>

I'm not sure. The only reason you'd want an atomic_bool for _M_owns is to 
make unique_lock tolerate data races. But it makes little sense to access an 
unique_lock from a thread which did not create it since only the thread that 
locked the mutex can unlock it. 



More information about the Gcc-patches mailing list