The functional relationship is confident - CMutex maps directly to the Mutex type of Win32, while std::mutex is more basic, probably implemented using win32 CRITICAL_SECTION , removing the recursive character and std::recursive_mutex wrapping CRITICAL_SECTION . They will work similarly to CCriticalSection .
CMutex is a heavyweight that is used in practice to create named mutexes for interprocess communication. You should not use its in-process.
If your question is to compare recursive_mutex vs CCriticalSection , I would put on almost the same performance. The CSingleLock interface has a full braindead interface (it takes a second argument, which defaults to FALSE instead of TRUE ), so in practice I have never used it directly through a macro only to avoid error.
In the new code, I first tried to solve everything using std::future , and a violin with locks only as a last resort. C ++ 11 threads make sense to use, so until you need CMultiLock functionality, it's better. I have not yet researched how to cover the latter case, but would be surprised if it is not easy to do.
source share