For two threads manipulating a container map for example, what the correct way to test whether an iterator still valid (for performance reason) ?
Or would be of only in
If your STL does not offer a thread safe std::map
, Intel's TBB offers a thread-safe concurrent_hash_map (pages 60 and 68).
Putting thread safety issues aside, std::map
does guarantee that deletions do not invalidate iterators other than the one being deleted. Unfortunately there isn't a is_iterator_valid()
method to validate iterators that you hold.
It may be possible to implement something like hazard pointers, and TBB has some workarounds to the problem as well.