Reader/Writer Locks in C++

c++, locking, multithreading

Solution

Newer versions of boost::thread have read/write locks (1.35.0 and later, apparently the previous versions did not work correctly).

They have the names `shared_lock`, `unique_lock`, and `upgrade_lock` and operate on a `shared_mutex`.

Problem

I'm looking for a good reader/writer lock in C++. We have a use case of a single infrequent writer and many frequent readers and would like to optimize for this. Preferable I would like a cross-platform solution, however a Windows only one would be acceptable.

Original source

Related problems