By: nksingh (nksingh.delete@this.live.com), December 6, 2014 3:42 am
Room: Moderated Discussions
Eric Bron (eric.bron.delete@this.zvisuel.privatefortest.com) on December 6, 2014 2:20 am wrote:
> > the compiler reducing the optimization possibilities. Having native atomics in C/C++ helps with that too.
>
> atomics are too low level for my use cases, but I have to confess that I still
> have to study (and maybe port my code to) the new C++ synchronization classes
>
> do you know if there is an equivalent to my example (using critical sections
> for locks) in the new C++ standard, I see there is std::lock_guard but it's based
> on std::mutex, so seems to map to Windows mutexes which is way too slow
>
A competent implementation of std::mutex should map to SRWLock or CriticalSection. The mingw implementation of std::mutex is not good in this regard, but the C++ runtime that comes with Visual Studio doesn't have that issue.
> > the compiler reducing the optimization possibilities. Having native atomics in C/C++ helps with that too.
>
> atomics are too low level for my use cases, but I have to confess that I still
> have to study (and maybe port my code to) the new C++ synchronization classes
>
> do you know if there is an equivalent to my example (using critical sections
> for locks) in the new C++ standard, I see there is std::lock_guard but it's based
> on std::mutex, so seems to map to Windows mutexes which is way too slow
>
A competent implementation of std::mutex should map to SRWLock or CriticalSection. The mingw implementation of std::mutex is not good in this regard, but the C++ runtime that comes with Visual Studio doesn't have that issue.