C++ 11 equivalent of java.util.ConcurrentHashMap

て烟熏妆下的殇ゞ 提交于 2019-12-12 08:46:03

问题


I find myself constantly writing Mutex code in order to synchronize read/write access to a std::unordered_map and other containers so that I can use them as I do java.util.concurrent containers. I was about to start writing a wrapper to encapsulate the Mutex, but I would rather use a well tested library so I don't stuff up the threading.

Is there such a library?


回答1:


Intel produced a library called Threading Building Blocks which has two such things: concurrent_hash_map and concurrent_unordered_map. They have slightly different characteristics, but one or the other will probably suit your needs.




回答2:


Folly has an AtomicHashmap implementation. The major limitation is that you can only use int32 or int64 keys. Check the documentation here (specially the Limitation section)



来源:https://stackoverflow.com/questions/16118889/c-11-equivalent-of-java-util-concurrenthashmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!