Re:Measuring mutexes, spinlocks and how bad the Linux schedu...
by gpderetta on Thursday January 02, 2020 @11:58AM
(#21937066)
Think 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.
Note: I wrote the above from the top of my head, I haven't actually had the need to implement a concurrent hashtable yet.