How to use lock_guard when returning protected data

前端 未结 3 732
半阙折子戏
半阙折子戏 2020-12-06 09:46

I have a question concerning the use of boost::lock_guard (or similar scoped locks) and using variables that should be protected by the lock in a return

3条回答
  •  有刺的猬
    2020-12-06 10:28

    Both pieces are equivalent. In fact for case #1 - C++ compiler will create structure described in case #2. So #1 is preferable.

提交回复
热议问题