4
votes

I have a scenario where multiple threads are writing to a common buffer (a map), each thread could or could not have the same key. Can someone please advise on whether i should use boost::shared_mutex or just boost::mutex? My understanding is that boost::shared_mutex is for a single writer and multiple reads which is not what i want. Does this make boost::mutex more appropriate for this scenario?

thanks in advance

1

1 Answers

5
votes

Yes, boost::shared_mutex is not your case as you don't have pure readers and have multiple writers. Just use boost::mutex to enforce exclusive access to shared data.