Threadsafe Vector class for C++

前端 未结 6 664
一整个雨季
一整个雨季 2020-12-03 03:58

Does anyone know a quick and dirty threadsafe vector class for c++? I am multithreading some code, and I believe the problem I have is related to the way the vectors are us

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 04:19

    As Scott Meyers explains in the effective STL book, by a thread safe container you can expect that:

    • Multiple reads are safe
    • Multiple writes to different containers are safe.

    Thats all. You can not expect many other things such as multiple writes to the same container be thread safe. If this is all what you want then you can take a look at STLPort. If not then the only option I see is to contain the vector in a class that synchronizes the access to the vector.

提交回复
热议问题