前言:
C++ 17开始,引入了两个新的同步组件, shared_mutex 和 shared_lock ,这两个组件的一个典型使用案例就是实现读写锁。
原语:
shared_mutex , 一个提供让多个线程都可以同时获取能力的mutex。
shared_mutx提供了两套接口:
Exclusive locking |
|
locks the mutex, blocks if the mutex is not available (public member function) |
|
tries to lock the mutex, returns if the mutex is not available (public member function) |
|
unlocks the mutex (public |