my map is as follow: std::map<int, int> BuffList = std::map<int, int>();
it's being used multiple times by multiple threads (insert,remove,find,count
) are the main functions.
When I test it by myself it works fine, but when its used by multiple people multiple times, the find function seems to return garbage values.
I also use critical section for the multithread handling.
Insert:
if (!buffCrit.IsLocked()) {
buffCrit.Enter();
BuffList[(PID + 4000000000 + (BuffID * 1000000))] = Value;
buffCrit.Leave();
}
Find
if (!buffCrit.IsLocked()) {
buffCrit.Enter();
if (BuffList.count((PID + 4000000000 + (BuffID * 1000000))))
Value = BuffList.find((PID + 4000000000 + (BuffID * 1000000)))->second;
buffCrit.Leave();
}
Any suggestion?
Aucun commentaire:
Enregistrer un commentaire