jeudi 17 octobre 2019

std::scoped_lock or std::unique_lock or std::lock_guard?

From this question I understand that std::scoped_lock is "a strictly superior version of std::lock_guard".

From this question I understand that "std::lock_guard and std::unique_lock are the same" except that std::unique_lock has some extra features (eg. try_lock) at the cost of some additional overhead.

How does std::scoped_lock compare with std::unique_lock?

Some related questions that I am hoping to get answered by this question.

  1. What are the differences between std::scoped_lock and std::unique_lock?
  2. In what situations should you use std::scoped_lock instead of std::unique_lock?
  3. In what situations should you use std::unique_lock instead of std::scoped_lock?
  4. Why does std::scoped_lock not implement some of the additional features of std::unique_lock?

Aucun commentaire:

Enregistrer un commentaire