相关疑难解决方法(0)

如何在C#中自动交换2个整数?

什么(如果有的话)是x86 asm xchg指令的C#等价物?

有了这个命令,哪个imo是一个真正的交换(不像Interlocked.Exchange),我可以简单地自动交换两个int,这就是我真正想做的事情.

更新:

示例代码基于我的建议.变量后缀"_V"被装饰为volatile:

// PART 3 - process links
// prepare the new Producer
address.ProducerNew.WorkMask_V = 0;
// copy the current LinkMask
address.ProducerNew.LinkMask_V = address.Producer.LinkMask_V;
// has another (any) thread indicated it dropped its message link from this thread?
if (this.routerEmptyMask[address.ID] != 0)
{
  // allow all other bits to remain on (i.e. turn off now defunct links)
  address.ProducerNew.LinkMask_V &= ~this.routerEmptyMask[address.ID];
  // reset
  this.routerEmptyMask[address.ID] = 0;
}
// PART 4 - swap
address.ProducerNew = …
Run Code Online (Sandbox Code Playgroud)

.net c# atomic

26
推荐指数
5
解决办法
8216
查看次数

标签 统计

.net ×1

atomic ×1

c# ×1