Lock free stack and queue in C#

后端 未结 4 830
一向
一向 2020-12-14 00:58

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 wra

相关标签:
4条回答
  • 2020-12-14 01:16

    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.

    0 讨论(0)
  • 2020-12-14 01:25

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

    0 讨论(0)
  • 2020-12-14 01:26

    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

    0 讨论(0)
  • 2020-12-14 01:27

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

    Pfx blog

    0 讨论(0)
提交回复
热议问题