Does std::mutex create a fence?

c++, memory-barriers, memory-model, multithreading, mutex

Solution

Unlocking a mutex synchronizes with locking the mutex. I don't know what options the compiler has for the implementation, but you get the same effect of a fence.

Problem

If I lock a `std::mutex` will I always get a memory fence? I am unsure if it implies or enforces you to get the fence. Update: Found this reference following up on RMF's comments. Multithreaded programming and memory visibility

Original source