I have a multithreaded app that has to read some data often, and occasionally that data is updated. Right now a mutex keeps access to that data safe, but it\'s expensive bec
It looks like you would do something like this:
boost::shared_mutex _access;
void reader()
{
// get shared access
boost::shared_lock lock(_access);
// now we have shared access
}
void writer()
{
// get upgradable access
boost::upgrade_lock lock(_access);
// get exclusive access
boost::upgrade_to_unique_lock uniqueLock(lock);
// now we have exclusive access
}