I have a map as member variable and multiple threads that access the map (read and write access). Now I have to ensure that only ONE thread have access to the map. But how do I dot that? What is the best solution for that?
Boost contains some nice lock implementations for shared access. Have a look at the documentation.
In your case you probably need a read-write lock because a mutual exclusion lock is probably overkill if you have a lot of reads and very few writes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With