c++ - Tbb concurrent hash map iterator -


i'm traversing entire tbb concurrent hash map using iterator , inspecting each (key,value) pair.

for (map::pair = myhashtable.begin(); myhashtable.end(); pair++) 

how can parallelize iterator?

use range() method described in reference manual:

hashtable_t myhashtable; // assuming hashtable_t concurrent_hash_map specialization tbb::parallel_for( myhashtable.range(), [](const hashtable_t::range_type &r) {     for( hashtable_t::iterator = r.begin(); != r.end(); i++); } ); 

(i use concision show types explicitly sake of )

and please pay attention caution note there:

do not call concurrent operations, including count , find while iterating table. use concurrent_unordered_map if concurrent traversal , insertion required.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -