C++ 11 等效于 java.util.ConcurrentHashMap [英] C++ 11 equivalent of java.util.ConcurrentHashMap
问题描述
我发现自己一直在编写 Mutex 代码,以便同步对 std::unordered_map 和其他容器的读/写访问,以便我可以像使用 java.util.concurrent 容器一样使用它们.我正要开始编写一个包装器来封装 Mutex,但我宁愿使用一个经过良好测试的库,这样我就不会塞满线程.
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.
有这样的图书馆吗?
推荐答案
Intel 制作了一个名为 Threading Building Blocks 的库,它有两个这样的东西:concurrent_hash_map 和 concurrent_unordered_map.它们的特征略有不同,但其中一种可能适合您需要.
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.
这篇关于C++ 11 等效于 java.util.ConcurrentHashMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!