std::shared...lock_shared(3)
π NAME π
std::shared_mutex::try_lock_shared β ok so it's literally std::shared_mutex::try_lock_shared, the shared-mode try-lock bestie of the C++ Standard Library manual (std::shared...lock_shared(3), iykyk) π«Ά
β¨ Synopsis β¨
bool try_lock_shared(); // (since C++17)
So here's the vibe: this function tries to lock the mutex in shared mode, and it returns immediately β no waiting, no blocking, no "hold on let me think about it" energy π
On a successful lock acquisition it returns true, otherwise it returns false. Periodt.
Heads up bestie: this function is allowed to fail spuriously and return false even if the mutex is not currently exclusively locked by any other thread π Not me getting rejected for no reason fr fr.
A prior unlock() operation on the same mutex synchronizes-with (as defined in std::memory_order) this operation if it returns true β
π¨ Ok this one matters: the behavior is undefined if the calling thread already owns the mutex in any mode. Any mode. Don't do it. π
π Parameters π
(none) β yeah, she takes nothing, she's low maintenance β¨
πΈ Return value πΈ
true if the lock was acquired successfully, otherwise false. That's it, that's the whole story π
π¦ Exceptions π¦
Throws nothing. Not a single thing. Iconic behavior honestly π
π Example π
This section is incomplete.
Reason: no example π
π See also π
lockβ locks the mutex, blocks if the mutex is not available (public member function)try_lockβ tries to lock the mutex, returns if the mutex is not available (public member function)unlock_sharedβ unlocks the mutex (shared ownership) (public member function)
π Category π
- Todo no example
π§ She's giving "I tried my best and I'm leaving immediately" energy and honestly? Respect.
Ok that's the whole page bestie, go forth and lock responsibly π β¨
Source/version + date check: this one's straight from http://cppreference.com, dated 2024.06.10 β the std::shared...lock_shared(3) page, no cap π«Άπ
π¦ 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