A question regarding std::shared_mutex and the acquiring of unique_lock.
Assume there are 3 threads:
- 2 readers (trying to
lock_shared()thestd::shared_mutex), and - 1 writer (trying to
lock[_unique]()thestd::shared_mutex)
Is it possible that the writer trying to lock[_unique]() would be starved? E.g.: at all times at least one reader owns a std::shared_lock, and lock[_unique]() can never succeed.
More or less: would lock[_unique]() on a std::shared_mutex block any attempts to further lock_shared() it?
(pretty sure boost::upgrade_lock could work here, but I'd like to know if there's any guarantee for bare std::unique_lock on a std::shared_mutex)
Aucun commentaire:
Enregistrer un commentaire