boost::lock_guard vs boost::mutex::scoped_lock

后端 未结 2 659
渐次进展
渐次进展 2020-12-30 19:25

Which is preferred boost::lock_guard or boost::mutex::scoped_lock?

I\'m using Boost.Thread with the hope to move to C++11 threading when it

2条回答
  •  遥遥无期
    2020-12-30 19:53

    Not much difference between the two. As per Boost, scoped_lock is a typedef for unique_lock. Both of unique_lock and lock_guard implement RAII-style locking. The difference between is simply that unique_lock has a more complex interface -- it allows to defer lock and call unlock.

提交回复
热议问题