Interlocked equivalent on Linux

后端 未结 7 1785
暗喜
暗喜 2020-12-10 12:39

In a C++ Linux app, what is the simplest way to get the functionality that the Interlocked functions on Win32 provide? Specifically, a lightweight way to atomically increme

相关标签:
7条回答
  • 2020-12-10 13:41

    You can insert some assembly code in your source, to use x68 interlocked instructions directly.

    You should use a lock xadd operation.

    See for instance this.

    0 讨论(0)
提交回复
热议问题