3 ms·
Interesting! Now I'm interested if there has been one usage case for the single bit spinlock in practice. It seems appropriate if writes aren't too numerous (we
by p0nce 7y ago
Interesting!
Now I'm interested if there has been one usage case for the single bit spinlock in practice. It seems appropriate if writes aren't too numerous (well leaving aside speed concerns).
Or a case where std::mutex was too large?
I've always wondered how the wait list was implemented.
- gpderetta 7y agoThink about a concurrent hashtable using chaining for collision resolution; distinct bucket chains can be updated concurrently, so you need a per bucket lock but you do not want a full std::mutex as it would increase the size of the bucket table by a large integer multiple. Instead, borrowing one bit from the chain pointer (you can easily arrange the least significant bit of the pointer to be always zero) is pretty much free. Note: I wrote the above from the top of my head, I haven't actually had the need to implement a concurrent hashtable yet.