I have a hash table data structure that I wish to make thread safe by use of a reader/writer lock (my read:write ratio is likely somewhere in the region of 100:1).
I have been looking around for how to implement this lock using C++11 (such as the method here), but it has come to my attention that it should be possible to use C++14's shared_lock
to accomplish the same thing. However, after looking on cppreference I have found both std::shared_lock
and std::unique_lock
but I don't understand how to use them together (compared to the Boost way which has simple method calls for locking both uniquely and in shared mode).
How can I recreate this relatively simple reader/writer lock interface in C++14 using only the standard library?