I am using tbb::concurrent_hash_map. I understand insertion and deletion are safe operations. Is iterating over hash map considered safe with respect to insertion and deletion. If not are there any data structures which I can use for safe iteration.
With the absence of memory reclamation support (GC) in C++ and TBB, it is not possible to make both deletion and iteration safe at the same time without significant performance impact. Thus TBB has 2 concurrent containers for hash tables:
concurrent_hash_map
with safe erase()
and element-level access synchronization but without safe iteration . concurrent_unordered_*
(eg concurrent_unordered_map
) without safe erase()
and element access synchronization but with thread-safe iteration support.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.