How can I use something like std::vector?

后端 未结 6 2230
暖寄归人
暖寄归人 2020-11-29 06:33

I have a large, but potentially varying, number of objects which are concurrently written into. I want to protect that access with mutexes. To that end, I thought I use a

6条回答
  •  孤街浪徒
    2020-11-29 06:52

    If efficiency is such a problem, I assume that you have only very small data structures which are changed very often. It is then probably better to use Atomic Compare And Swap (and other atomic operations) instead of using mutexes, specifically std::atomic_compare_exchange_strong

提交回复
热议问题