The SharedMutex requirements extend the Mutex requirements to include shared lock ownership mode.
Additionally, an object m
of SharedMutex type supports another mode of ownership: shared. Multiple threads (or, more generally, execution agents) can simultaneously own this mutex in shared mode, but no thread may obtain shared ownership if there is a thread that owns it in exclusive mode and no thread may obtain exclusive ownership if there is a thread that owns it in shared mode. If more than implementation-defined number of threads (no less than 10000) hold a shared lock, another attempt to acquire the mutex in shared mode blocks until the number of shared owners drops down below that threshold.
m.lock_shared()
has the following properties m.unlock()
operations on the same mutex synchronize-with this lock operation (equivalent to release-acquire std::memory_order
) m.try_lock_shared()
has the following properties try_lock_shared()
succeeds, prior unlock()
operations on the same object synchronize-with this operation (equivalent to release-acquire std::memory_order
). m.unlock_shared()
has the following properties The following standard library types satisfy SharedMutex:
std::shared_mutex
(since C++17) std::shared_timed_mutex
(since C++14)
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/named_req/SharedMutex