C ++ 11等价于java.util.ConcurrentHashMap [英] C++ 11 equivalent of java.util.ConcurrentHashMap

查看:203
本文介绍了C ++ 11等价于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生产了一个名为线程构建模块,它有两个这样的东西: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆