.NET ConcurrentStack,在推送操作中缺少exp退避

时间:2016-03-25 09:30:58

标签: .net algorithm concurrency lock-free

我发现.NET ConcurrentStack实现在Pop方法中第一次失败的CAS操作之后使用指数退避,但在Push方法中没有。

http://referencesource.microsoft.com/#mscorlib/system/Collections/Concurrent/ConcurrentStack.cs (pushCore,popCore方法)

我想,在CAS操作失败后,最好不要立即重试,因为下一次尝试可能会在高负荷下再次失败。这种(不仅仅是)为什么在这种无锁算法中使用指数退避。

有人可以解释一下,为什么这可以在Push方法中省略,但不能在Pop方法中省略?

0 个答案:

没有答案