shared_lock<std::shared_mutex>
时间: 2023-11-16 14:51:47 浏览: 93
shared_spin_mutex:共享自旋互斥锁
shared_lock<std::shared_mutex>是C++中用于管理std::shared_mutex的共享锁的类。它可以在多个线程中同时获得对共享资源的读取访问权。\[1\]在使用shared_lock<std::shared_mutex>时,通常会将其与std::shared_mutex一起使用,以实现对共享资源的并发读取操作。\[1\]例如,在dns_cache类的find_entry函数中,使用shared_lock<std::shared_mutex>来获取对entries的共享访问权,以允许多个线程同时读取entries中的数据。\[2\]这样可以提高并发性能,因为多个线程可以同时读取共享资源而无需互斥锁定。
#### 引用[.reference_title]
- *1* *3* [C++互斥对象std::mutex与std::shared_mutex;互斥锁:std::lock_guard、std::unique_lock与std::shared_...](https://blog.csdn.net/qq_33726635/article/details/109693403)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [c++之std::unique_lock, std::lock, std::scoped_lock及std::condition_variable](https://blog.csdn.net/weixin_44537992/article/details/122734223)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文