Simplified example
class A
{
//some public functions
void addValue(string key, string value);
std::set getValues(string key);
void deleteKey(string key)
private:
std::map<string, std::set<std:string>> map;
};
Class A has public methods for adding elements into map, adding more elements to the set with given string key, and removing elements from map. It will be accessed from different threads so all operation with map should be thread-safe. I can use std::shared_mutex, but in this case when one thread do something with one key, all other thread that maybe want to access some other keys will be blocked. I thought it's a common issue, but seems like with standard library there isn't anything that can help to solve this. Is there something in maybe boost?
Aucun commentaire:
Enregistrer un commentaire