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;
inserting mymap:
string key = "somestring" int somevalue = 1 mymap[key].push_back(somevalue);
iterating through keys in mymap:
boost_foreach(map::value_type pair, mymap) { string key = pair.first; }
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
Post a Comment