您当前的位置: 首页 > 
  • 0浏览

    0关注

    1477博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

TBB concurrent_unordered_map哪些操作可以并发

软件工程小施同学 发布时间:2021-11-08 20:55:06 ,浏览量:0

As stated in the document (concurrent_unordered_map — oneAPI Specification 1.0-rev-3 documentation).

tbb::concurrent_unordered_map is a class template that represents an unordered associative container. It stores key-value pairs with unique keys and supports concurrent insertion, lookup, and traversal, but does not support concurrent erasure.

Does it mean the following?

  1. A thread with an insertion can be concurrent with another thread with an insertion without using locks.
  2. A thread with an insertion can be concurrent with another thread with a lookup without using locks.
  3. A thread with an insertion can be concurrent with another thread with a traversal without using locks.
  4. A thread with an insertion can be concurrent with another thread with an erasure without using locks.
  5. A thread with an lookup can be concurrent with another thread with an erasure without using locks.
  6. ......
  7. A thread with an erasure can not be concurrent with another thread with an erasure without using locks.

Am I right? Looking forward to your reply, thank you very much.

Thank you for your question! You are right, concurrent_unordered_map can be used by different threads with insertion, traversal and lookup without any additional synchronization.

Erasure operations (as well as any other operations, such as clear, assignment operators, bucket interfaces, swap, etc.) can not be used simultaneously with other operations. Such a methods can only be used in "serial" parts of the application, when other threads do not perform any operations on the container. In concurrent part, it can be achieved with writer lock around the unsafe operation.

I am very confused about which operations can be concurrent · Issue #640 · oneapi-src/oneTBB · GitHub

关注
打赏
1665320866
查看更多评论
立即登录/注册

微信扫码登录

0.0439s