- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I was trying to use tbb::concurrent_map, and was wondering does a mutable iterator provide exclusive access to the key (similar to concurrent_hash_map's accessor), and similarly a const_iterator shared read access? I was looking at the source code, and wasn't able to find such a capability, but I just wanted to be sure?
If not, to clarify, concurrent_map just protects its internal structure from concurrent modification, not necessarily the values themselves? In that case, I was thinking of simply adding a pthread_rwlock_t to my values and doing r/w locking manually- I was wondering if there is a better approach leveraging the concurrent_map's APIs?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel Communities.
Yes, you are correct. In tbb::concurrent_map, the mutable iterator does not provide exclusive access to the key.
Please refer to the below links for more information.
If you are looking for thread safety, you can use tbb::concurrent_hash_map which is designed for parallelism and provides built-in support for thread-safe access to the values which are stored in the map.
You can refer to the OneTBB Pro Textbook, page no:186 for more information.
Thanks and Regards,
Pendyala Sesha Srinivas
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel Communities.
Yes, you are correct. In tbb::concurrent_map, the mutable iterator does not provide exclusive access to the key.
Please refer to the below links for more information.
If you are looking for thread safety, you can use tbb::concurrent_hash_map which is designed for parallelism and provides built-in support for thread-safe access to the values which are stored in the map.
You can refer to the OneTBB Pro Textbook, page no:186 for more information.
Thanks and Regards,
Pendyala Sesha Srinivas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh ok, thank you for this answer!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Thanks and Regards,
Pendyala Sesha Srinivas

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page