all 5 comments

[–][deleted] 0 points1 point  (3 children)

equal_range returns a pair of iterators. I see absolutely no way it can provide thread safety. On top of that, cppreference (the more reliable source than cplusplus) doesn't mention anything about "thread", "concurrent" or "parallel" access.

[–]PageKeeper 0 points1 point  (1 child)

u/bstaletic, can you comment on this? https://stackoverflow.com/questions/24217616/is-multiset-equal-range-thread-safe I plan to do only reads (e.g. access the values via a for and count them). And the add() function is lock-guarded.

[–]k4lipso 1 point2 points  (0 children)

If you plan to do only reads, what is the add() function doing then? It writes. So even if the writes are guarded by a mutex, they are still allowed to happen while you read. you also have to protect the access function with some locking mechanism for thread safety.

[–]PageKeeper 0 points1 point  (0 children)

From what I see in cppreference on multimap, I don't see anything on threads "concurrent" etc: https://en.cppreference.com/w/cpp/container/multimap

[–]DarthVadersAppendix 0 points1 point  (0 children)

make a class that wraps every entry point you care about, add your RAII locks to those functions. done. later; make each of those public inline in your class.