【问题标题】:tbb::concurrent_multiset/concurrent_set crashes when using unsafe_erase() to erase begin()tbb::concurrent_multiset/concurrent_set 在使用 unsafe_erase() 擦除 begin() 时崩溃
【发布时间】:2021-12-15 05:05:08
【问题描述】:

我的代码如下,我使用.begin()获取集合中的第一个元素,可以正确获取,但是使用.unsafe_erase(iterator)经常会crash。当然,第一行(WriteGuard)是写锁。

我不知道为什么会这样,谁能给我一些建议,提前谢谢

【问题讨论】:

    标签: c++ tbb


    【解决方案1】:

    concurrent_set/concurrent_multiset 支持并发插入和遍历,但不支持并发擦除。 您可以参考以下链接了解更多详情: https://spec.oneapi.io/versions/0.5.0/oneTBB/containers/concurrent_set_cls.html

    从 oneTBB 2021 开始,concurrent_set 的实现在内部发生了变化。您可以尝试使用最新版本的 oneTBB (2021.4)。

    您可以从以下链接下载 oneTBB 独立组件: https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html

    您也可以尝试使用开源 oneTBB

    https://github.com/oneapi-src/oneTBB/releases/tag/v2021.4.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多