Reputation: 53
I have a map which looks like this: std::map<int, class A*> m
. I have two threads: one of them is reading m
and updating the values of the object contained and the other one is reading and writing (removing elements). Is there a way to make it thread-safe without using mutexes?
Upvotes: 1
Views: 149
Reputation: 254471
Is there a way to make it thread-safe without using mutexes?
No.
You might be able to write your own lock-free map, perhaps with ideas like this, or try third-party libraries like this, but the standard map gives no thread safety guarantees.
Upvotes: 4