Partilhar via


Writing your own lock-free reader/writer lock

It is sort of puzzling for me why C++ standard doesn't have a implementation of reader/writer lock. So just like every other C++ developer, I've decided to roll my own. 

A typical implementation might be using semaphore / mutex. However, this has a major disadvantage that it requires entering a lock mutex every time a reader comes in, and this can be expensive as this usually leads to a kernel transition that are costly and can become a bottle neck when multiple readers are trying to access. A lock-free implementation avoids these overhead/bottleneck and allows for better throughput.  

I've moved my blog over to yizhang82.me. You can find the full post here: https://yizhang82.me/lock-free-rw-lock