I am currently using Facebook's concurrent hash map and I am wondering if something like this would be possible:
folly::ConcurrentHashMap<std::string, some_class> m;
// add some elements
const auto it = m.find("a");
// during this time, another thread removes the "a" element
if (it != m.end())
it->second.something(); // it is now an invalid iterator
After reading through the source of the hash map, I came across this:
Iterators hold hazard pointers to the returned elements. Elements can only be accessed while Iterators are still valid!
This is pretty unsettling and it feels like using any returned iterators are unsafe, is this so?