Does std::mutex create a fence?

前端 未结 3 1595
心在旅途
心在旅途 2020-12-05 17:23

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 referen

3条回答
  •  -上瘾入骨i
    2020-12-05 18:05

    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.

提交回复
热议问题