Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does tbb::concurrent_unordered_map::unsafe_erase invalidate any existing iterators?

I see that tbb::concurrent_unordered_map hews pretty close to std::unordered_map while being safe for concurrency. I also know that unsafe_erase is not concurrent-safe with insert etc. The iterator docs also state that any existing iterators are still valid with insert, find etc.

The question is, does unsafe_erase invalidate any other iterator than the one it is asked to erase?

std::unordered_map and std::map certainly have this behavior, but it's not specified in the concurrent_unordered_map docs anywhere.

like image 212
Glen Low Avatar asked Nov 07 '13 03:11

Glen Low


1 Answers

tbb::unsafe_erase does not invalidate other iterators. This is a property that we should document.

The reason that it does not invalidate other iterators is that the underlying implementation is a split-ordered list, and an iterator just points into that list.

like image 150
Arch D. Robison Avatar answered Oct 17 '22 14:10

Arch D. Robison