Jump to content
  • Advertisement
Sign in to follow this  

Should I use boost::upgrade_lock or just boost::unique_lock?

This topic is 2854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, is it much better to use boost::upgrade_lock and only change to boost::upgrade_to_unique_lock at a later stage, or should I just start off by using a boost::unique_lock??

for e.g

void FunctionA()
boost::shared_lock<boost::shared_mutex> read_lock(read_write_mutex_);

HashMap::iterator iter hash_map_.find("value");

if (hash_map_.end() == iter)
boost::upgrade_to_unique_lock<boost::shared_mutex> write_lock(read_lock);

iter->second.value = 1000;

is that better or should I just use a unique lock at the start and do a exclusive lock all the way till the function ends?


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!