1

I develop a module with multiple threads and one Cache in std::map. Some times I need to update cache. In that time all readers must wait, while I do update map. How can I do this synchronization with boost library?
P.S.: some time ago in Boost was read_write_mutex. But in current releases of Boost it missed.

Vitaly Dyatlov
  • 1,872
  • 14
  • 24

1 Answers1

4

will shared_mutex replace read_write_mutex?

Yes.

...

Basically unique_lock<shared_mutex> will give you a write lock, shared_lock<shared_mutex> will give you a read lock, and upgrade_mutex<shared_mutex> will give you a read lock than you can upgrade by transferring ownership (with move) to a unique_lock<shared_mutex>.

http://lists.boost.org/Archives/boost/2008/01/132656.php

Tim Sylvester
  • 22,897
  • 2
  • 80
  • 94