std :: mutex is implemented with critical partitions, so it is much faster than OS Mutex (on Windows). However, this is not as fast as Windows CRITICAL_SECTION.
Reading time only in a closed loop in one thread:
423.76ns ATL CMutex 41.74ns std::mutex 16.61ns win32 Critical Section
My question is, what else does std :: mutex do? I looked at the source, but could not trace it. However, there were additional steps before he moved on to Crit Sec. My questions are: are these additional steps helpful? That is, what are the additional steps; What would I skip using CRITICAL_SECTION?
And why did they call it Mutex if it is not implemented using Mutex?
c ++ mutex c ++ 11 winapi critical-section
Philip
source share