Does anyone have a good example of using concurrent_hash_map::erase()?
I have been trying to get this working for the last week, and it appears that it will let me erase a key twice (returns tru in both threads), even though the documents indicate otherwise. Also how are you supposed to when to free the contents of the hash element?
For instance:
tbb::concurrent_hash_map my_map;
some threads:
tbb::concurrent_hash_map::accessor acc_w;
if(my_map.insert(acc_w, new_Key)) {
acc_w->second = new Item();
}
some more threads:
if(my_map.erase(acc_w, some_Key)) {
// get here multiple times for same Key
// don't know what pointer is to free it - could do a find and stash pointer, but since Keys
// can be reused, the contents could change between the find() and the erase()
}
I also tried defining the map just as:
tbb::concurrent_hash_map my_map;
But couldn't get this working as Item has dynamically allocated data members in it, and despite putting in a copy constructor and assignment operators couldn't get it to work.
thanks for any assistance.
Simon Cope



