Does Interlocked.CompareExchange use a memory barrier?

前端 未结 6 1001
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 18:55

I\'m reading Joe Duffy\'s post about Volatile reads and writes, and timeliness, and i\'m trying to understand something about the last code sample in the post:

<         


        
6条回答
  •  孤城傲影
    2020-11-27 19:27

    According to ECMA-335 (section I.12.6.5):

    5. Explicit atomic operations. The class library provides a variety of atomic operations in the System.Threading.Interlocked class. These operations (e.g., Increment, Decrement, Exchange, and CompareExchange) perform implicit acquire/release operations.

    So, these operations follow principle of least astonishment.

提交回复
热议问题