tags:

views:

224

answers:

1

Hi! 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.

+3  A: 

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
Thanks Tim!Don't knew this.
Vitaly Dyatlov