Lock free stack and queue in C#

自古美人都是妖i 提交于 2019-11-27 12:00:15

问题


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


回答1:


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




回答2:


Do you mean the container classes like they exist in the PFX framework (Parallels for .NET), ConcurrentQueue & ConcurrentStack

Pfx blog




回答3:


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.




回答4:


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..



来源:https://stackoverflow.com/questions/550616/lock-free-stack-and-queue-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!