c#中的原子读取模式写入
-
10-10-2019 - |
题
我已经看到几个地方引用了C#规格的以下位置:“除了为该目的设计的库函数外,也不能保证原子读取模式 - 撰写。”有人可以将我指向这些图书馆的功能吗?
其他提示
我认为这是指诸如 Interlocked.CompareExchange
.
此方法可用于(例如,原子上) double
:
static void Add(ref double field, double amount)
{
double before, after;
do
{
before = field;
after = before + amount;
}
while (Interlocked.CompareExchange(ref field, after, before) != before);
}
不隶属于 StackOverflow