std::shared...lock_shared(3)
π
std::shared...lock_shared(3) β C++ Standard Libary bestie page π
okay bestie, welcome to the manual page for std::shared...lock_shared(3) from the C++ Standard Libary (thatβs the manual name, donβt come for me π). Hydrate, stretch, and letβs get into this shared-lock situation. π«Άβ¨
πΈ NAME πΈ
std::shared_timed_mutex::try_lock_shared - std::shared_timed_mutex::try_lock_shared
π Synopsis π
bool try_lock_shared(); (since C++14)
okay so this function tries to lock the mutex in shared mode. It returns immediately β no blocking, no waiting, no βgimme a sec.β If the lock acquisition is successful it returns true; otherwise it returns false. π
Heads up though: this function is allowed to fail spuriously and return false even if the mutex is not currently exclusively locked by any other thread. So a false doesnβt always mean someone else is holding it exclusively β rude, but legal. π
If a prior unlock() operation on the same mutex happens, it synchronizes-with (as defined in std::memory_order) this operation when this one returns true. Thatβs the memory-order tea. π΅
β οΈ UNDEFINED BEHAVIOR ALERT: the behavior is undefined if the calling thread already owns the mutex in any mode. Do not do that. Not even a little. π
π Parameters π
Literally none. Zero. Nada. This function takes no parameters. π§
β Return value β
true if the lock was acquired successfully, otherwise false. Thatβs it. Thatβs the whole vibe check. β
π¦ Exceptions π¦
It throws absolutely nothing. Not a single exception. Silent. Iconic. β¨
π Example π
This section is incomplete Reason: no example
Yeah bestie, they really left us hanging β no example here. π
π₯ 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
made with π by http://cppreference.com β version/date: 2024.06.10 ππ«Ά
π¦ 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