c++ - Converting from boost unordered to tbb concurrent hash map -


i new c++ , have been searching, in vain, beginner's tutorial on tbb concurrent hash map. have been using boost unordered hash map in c++ program, , use tbb's concurrent hash map since multiple threads writing hash map @ once.

i doing following 4 operations on boost's hash map:

typedef boost::unordered_map<string, std::vector<int> > map; map mymap; 
  1. inserting mymap:

    string key = "somestring" int somevalue = 1  mymap[key].push_back(somevalue); 
  2. iterating through keys in mymap:

    boost_foreach(map::value_type pair, mymap) {         string key  = pair.first; } 
  3. returning value associated key:

    map::const_iterator iter = mymap.find("somekey"); 

how can achieve 1, 2, , 3, using tbb concurrent hash map? note perform 2 , 3 after threads done inserts

you should able change typedef typedef tbb::concurrent_unordered_map<string, std::vector<int> > map; , use container multiple threads safely.

the insert, iterators (begin .. end) , find methods work in same way, unlike unordered_map thread safe.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -