I’ve got an instance of an std::unordered_map serving as a database of some sort. (It’s basically just a regular hashmap).
I have 4 threads retrieving long strings from a network (I’m using the c++11 std::threads) and within each of those threads, i tokenize the strings they receive. The tokenization itself is paralellized as well using the new Microsoft AMP library (so the process of tokenization is done by the GPU threads).
I would like each of the 4 “main” threads to add the tokens as keys into the hashmap as the GPU threads finish tokenizing the strings (and then repeat the process).
How would i go about synchronizing all of this so that i can safely add new keys into my database from each of the threads ?
use concurrent_unordered_map instead of unordered_map in concurrent_unordered_map.h