Interlocked and Memory Barriers

前端 未结 7 2010
情书的邮戳
情书的邮戳 2021-02-02 18:04

I have a question about the following code sample (m_value isn\'t volatile, and every thread runs on a separate processor)

void Foo() // executed by thr         


        
7条回答
  •  梦如初夏
    2021-02-02 18:45

    I'm not completely sure but I think the Interlocked.Exchange will use the InterlockedExchange function of the windows API that provides a full memory barrier anyway.

    This function generates a full memory barrier (or fence) to ensure that memory operations are completed in order.

提交回复
热议问题