Lock free stack and queue in C#

20,576

Solution 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

Solution 2

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

Pfx blog

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

Share:
20,576
Radu094
Author by

Radu094

Computer-lover Started programming back in the days of Commodore 64, saving my lovely programs on tape. Now I talk to my computer every day, patting the monitor on the back when it does something pretty. OCD Not so much since I started taking medication. I need to keep all code clean, brackets in the right place, project architecure must be just right and beautifull or I'm losing sleep at night. Workahoolic Not having a real life helps

Updated on June 23, 2020

Comments

  • Radu094
    Radu094 almost 4 years

    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