std::shared...lock_shared(3)
std::shared_timed_mutex::lock_shared π
π¦
okay so bestie, welcome to the C++ Standard Libary manual page for std::shared_timed_mutex::lock_shared. We're gonna get you comfy with this shared-locking situation, and yes, the manual name is folded right in here near the top. No cap. β¨
β¨ NAME β¨
std::shared_timed_mutex::lock_shared - std::shared_timed_mutex::lock_shared. That's it, that's the name, twice, because the page said so. It's giving "shared lock member function" main character energy. π
β¨ Synopsis β¨
void lock_shared(); (since C++14)
So the lore: lock_shared() acquires shared ownership of the mutex. If another thread is holding the mutex in exclusive ownership, a call to lock_shared will block execution until shared ownership can be acquired. Like, it waits its turn, periodt. π
If lock_shared is called by a thread that already owns the mutex in any mode (exclusive or shared), the behavior is undefined. Not "oops maybe fine" β undefined, bestie, so don't do it. π
If more than the implementation-defined maximum number of shared owners already locked the mutex in shared mode, lock_shared blocks execution until the number of shared owners is reduced. The maximum number of owners is guaranteed to be at least 10000. That's a big group chat, but there is a cap. π
Prior unlock() operation on the same mutex synchronizes-with (as defined in std::memory_order) this operation. That's the memory-ordering lore, iykyk. π
β¨ Parameters β¨
(none) β literally zero parameters. Not one. Nada. π
β¨ Return value β¨
(none) β it's void, so nothing comes back. It's giving silent but powerful. π
β¨ Exceptions β¨
Throws std::system_error when errors occur, including errors from the underlying operating system that would prevent lock from meeting its specifications. The mutex is not locked in the case of any exception being thrown. So if it throws, it's not secretly holding the lock. π
β¨ Notes β¨
lock_shared() is usually not called directly: std::shared_lock is used to manage shared locking. So you'll probably meet std::shared_lock first, and it's the main character managing the shared locking vibes. π
β¨ Example β¨
This section is incomplete Reason: no example
bestie, there is literally no example here. The page says so. π
β¨ See also β¨
lockβ locks the mutex, blocks if the mutex is not available (public member function)try_lock_sharedβ tries to lock the mutex for shared ownership, returns if the mutex is not available (public member function)unlock_sharedβ unlocks the mutex (shared ownership) (public member function)
β¨ Category β¨
* Todo no example
kisses and shared locks, bestie π β source: http://cppreference.com, date: 2024.06.10, page footer: std::shared...lock_shared(3). slay. β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms