Suppose I have the following code:
#include<concurrent_unordered_map.h>
struct firstStruct {
<irrelevant code>
}
struct secondStruct {
void func(){
<CRITICAL CODE>
}
}
Let's suppose I have this:
concurrent_unordered_map<firstStruct,secondStruct> cmap = ...
and let's assume that that cmap has been populated, and that firstStruct f and secondStruct s are a (key,value) pair (f,s) that exist in cmap.
If I were to use the following code snippet
cmap[f].func();
Would the execution of the <CRITICAL CODE> in func() from secondStruct s be thread-safe?
Additionally, what would happen if I had the following code snippets, potentially being executed at the same time in different threads?
cmap[f].func();
and
SecondStruct s2 = ... ;
cmap[f] = s2;
If the (key,value) pair (f,s) was changed to (f,s2) by one thread, what would happen if another thread happens to be executing the <CRITICAL CODE>?