Get the latest tech news
Properly testing concurrent data structures
There's a fascinating Rust library, loom, which can be used to thoroughly test lock-free data structures. I always wanted to learn how it works. I still do! But recently I accidentally implemented a small toy which, I think, contains some of the loom's ideas, and it seems worthwhile to write about that. The goal here isn't to teach you what you should be using in practice (if you need that, go read loom's docs), but rather to derive a couple of neat ideas from first principles.
The goal here isn’t to teach you what you should beusing in practice (if you need that, go read loom’s docs), but rather to derive a couple of neatideas from first principles. So, in the spirit of faking, let’s just write a PBT using these pausable, managed threads, even ifwe still have no idea how to actually implement pausing. No need for annoyance — when writing this code for the first time, I tracedexactly these steps — I realized that I need a “pausing AtomicU32 ” so I did that (with dummypause calls), then I played with the API I wanted to have, ending at roughly this spot, withoutyet knowing how I would make it work or, indeed, if it is possible at all.
Or read this on Hacker News