concurrent_unordered_map in c++

concurrent_unordered_map in c++

本文关键字:c++ in unordered concurrent map      更新时间:2023-10-16

我有一个串行运行的算法,我将并行化它。现在,此算法使用 C++11 中的unordered_map。我可以用concurrent_unordered_map直接代替它吗?

我只想指出,我已经尝试过这样做,但它似乎会产生难以理解的错误。像这个:

(.text._ZN3tbb13tbb_allocatorINS_10interface58internal18split_ordered_listISt4pairIKSsSt6vectorIjSaIjEEENS0_IS9_EEE4nodeEE8allocateEjPKv[tbb::tbb_allocator<tbb::interface5::internal::split_ordered_list<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<unsigned int, std::allocator<unsigned int> > >, tbb::tbb_allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<unsigned int, std::allocator<unsigned int> > > > >::node>::allocate(unsigned int, void const*)]+0x16): undefined reference to `tbb::internal::allocate_via_handler_v3(unsigned int)'

concurrent_unordered_map允许并发插入和并发读取,但不允许并发删除。 因此,只要您在添加/迭代时不删除,您应该没问题。

  • 上述评论中提到的链接问题。