std::shared_lock::try_lock(3)
π NAME π
okay so bestie, welcome to the std::shared_lock::try_lock page from the C++ Standard Libary manual β¨ the name is std::shared_lock::try_lock β and yes, it is also literally std::shared_lock::try_lock. iconic redundancy, we love to see it π
πΈ Synopsis πΈ
bool try_lock(); (since C++14)
Tries to lock the associated mutex in shared mode without blocking π«Ά Effectively calls mutex()->try_lock_shared().
std::system_error is thrown if there is no associated mutex or if the mutex is already locked. no cap, that's the whole vibe check π
π Parameters π
(none) β not a single parameter, bestie. zero. nada. π
β¨ Return value β¨
true if the ownership of the mutex has been acquired successfully, false otherwise. periodt π
π Exceptions π
- Any exceptions thrown by
mutex()->try_lock_shared()β yes, whatever that throws, you get it π - If there is no associated mutex,
std::system_errorwith an error code ofstd::errc::operation_not_permitted. - If the mutex is already locked,
std::system_errorwith an error code ofstd::errc::resource_deadlock_would_occur.
bestie this is the βnot todayβ section, okay? if there's no associated mutex or it's already locked, std::system_error is coming for you πβ¨
π§ Example π§
This section is incomplete Reason: no example
literally the manual page said βno exampleβ and left it at that ππ
π¦ See also π¦
lockβ locks the associated mutex (public member function)try_lockβ tries to lock (i.e., takes ownership of) the associated mutex without blocking (public member function ofstd::unique_lock<Mutex>)try_lock_forβ tries to lock the associated mutex, for the specified duration (public member function)try_lock_untilβ tries to lock the associated mutex, until a specified time point (public member function)unlockβ unlocks the associated mutex (public member function)
π Category π
- Todo no example
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page tag: std::shared_lock::try_lock(3) β okay bye bestie, mwah πβ¨π¦
π¦ 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