Thread-safe C++ stack

后端 未结 6 1373
余生分开走
余生分开走 2021-01-30 18:56

I\'m new to C++ and am writing a multi-threaded app whereby different writers will be pushing objects onto a stack and readers pulling them off the stack (or at least pushing th

6条回答
  •  一个人的身影
    2021-01-30 19:20

    The current C++ standard doesn't address threading at all, so the answer to your first question is no. And in general, it is a bad idea to build locking into basic data structures, because they don't have sufficient information to perform it correctly and/or efficiently. Instead, the locking should be performed in the classes that use the data structures - in other words, in your own application classes.

提交回复
热议问题