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

Change the color of an oval at click in Java AWT -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -