C# 中锁定空闲堆栈和队列
有谁知道是否有可用于 .NET 的无锁容器库?
最好是经过证明可以工作并且比 .NET 中的同步包装器更快的东西。
我在 .NET 上找到了一些文章,但它们都没有指定任何速度基准测试,也没有激发人们对其可靠性的信心。
谢谢
Does anyone know if there are any lock-free container libraries available for .NET ?
Preferably something that is proven to work and faster than the Synchronized wrappers we have in .NET.
I have found some articles on the .NET, but none of them specify any speed benchmarking, nor do they inspire much confidence in their reliability.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
迟到了,但总比没有好,我想我会将朱利安·巴克纳尔斯的文章添加到这个列表中。
但他没有表现数据。 在我对其结构的测试中,与锁定相比,列表的扩展性很好(与 ReaderWriterLock 相比,内核使用率非常低)。
他的博客有一系列有关 C# 中无锁结构的文章。
无锁数据结构:堆栈
Late, but better than never I thought I would add Julian Bucknalls articles to this list.
But he does not have performance numbers. In my testing of his structures the list scaled well compared to locking (very low kernel usage compared to ReaderWriterLock).
His blog has a series of articles on lock free structures in C#.
LOCK-FREE DATA STRUCTURES: THE STACK
您的意思是像 PFX 框架(Parallels for .NET)、ConcurrentQueue 和 ConcurrentQueue 中存在的容器类一样吗? ConcurrentStack
Pfx 博客
Do you mean the container classes like they exist in the PFX framework (Parallels for .NET), ConcurrentQueue & ConcurrentStack
Pfx blog
在对此一无所知的情况下,我在此处偶然发现了一个库。
虽然可能不完全是你想要的,但至少在 StackOverflow 上有一个 这里是 C# 中的无锁队列结构。 通过 StackOverflow 代码审查流程可能会给您带来一些对其安全性的信心,或者提供有关如何自行构建无锁容器的信息。
Without knowing anything about it, there is one library I stumbled across here.
Though probably not quite what you are looking for, at least there is an implementation and discussion on StackOverflow of a lock free queue structure in C# here. Going through the StackOverflow code review process might give some confidence about its safety, or provide information about how to go about building your lock-free containers yourself.
无锁数据结构将会出现问题,直到它们用内存模型造成的混乱修改 CLR,请参阅 CLI 规范。
顺便说一句,无锁编程非常困难,您不应该在集合(容器)级别上为它操心。 对于任何语言都是如此。
Lock free data structures are going to have issues until they modify the CLR with the mess caused by memory models, see the CLI spec.
Lock-free programming is sufficiently difficult that you shouldn't bother with it on a collection (container) level btw. True for any language out there..