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.
Asked
Active
Viewed 565 times
1

Vitaly Dyatlov
- 1,872
- 14
- 24
-
Duplicate http://stackoverflow.com/questions/244316/reader-writer-locks-in-c – Kirill V. Lyadvinsky Aug 28 '09 at 20:11
1 Answers
4
will
shared_mutex
replaceread_write_mutex
?Yes.
...
Basically
unique_lock<shared_mutex>
will give you a write lock,shared_lock<shared_mutex>
will give you a read lock, andupgrade_mutex<shared_mutex>
will give you a read lock than you can upgrade by transferring ownership (with move) to aunique_lock<shared_mutex>
.

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