问题描述
我发现自己不断地写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生产了一个名为,它有两个这样的东西: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!