STD::SHARED_LOCK(3)
π NAME π
std::shared_lock< _Mutex > β bestie, that's it, that's the name. It's shared_lock. Short, sweet, iconic. β¨
π¦ SYNOPSIS π¦
#include <shared_mutex>
Okay so first things first, you gotta pull in the header. That's the whole entry fee. π
π Public Types π
typedef _Mutex mutex_typeβ the mutex type you're working with gets typedef'd tomutex_type, so you can stop typing out the whole template situation every single time. Slay.
πΈ Public Member Functions πΈ
shared_lock (mutex_type &__m)β constructor taking a reference to your mutex, named__m. Simple. Clean. Main character.shared_lock (mutex_type &__m, adopt_lock_t)β same mutex ref__m, plus anadopt_lock_ttag riding along. π«Άtemplate<typename _Rep, typename _Period> shared_lock (mutex_type &__m, const chrono::duration< _Rep, _Period > &__rel_time)β template constructor: your__mplus achrono::duration< _Rep, _Period >reference called__rel_time. Yes,chrono::duration, exactly like that, no cap.template<typename _Clock, typename _Duration> shared_lock (mutex_type &__m, const chrono::time_point< _Clock, _Duration > &__abs_time)β the time-point sibling:__mplus achrono::time_point< _Clock, _Duration >reference named__abs_time. π₯shared_lock (mutex_type &__m, defer_lock_t) noexceptβ__mplus adefer_lock_ttag, and it's markednoexceptso it's promising not to throw. πshared_lock (mutex_type &__m, try_to_lock_t)β__mplus atry_to_lock_ttag. Nonoexcepton this one, just saying. πshared_lock (shared_lock &&__sl) noexceptβ move constructor, takesshared_lock &&__sl, and it'snoexcept. Moves are the vibe.shared_lock (shared_lock const &)=deleteβ copy constructor is deleted. Like, literally not available. Do not attempt, bestie, it will not compile. πvoid lock ()β returnsvoid, takes nothing. It's justlock().mutex_type * mutex () const noexceptβ returns amutex_type *, and it'sconst noexcept. Pointer delivery service.operator bool () const noexceptβ the bool conversion operator,const noexcept. Very "am I valid" energy, iykyk.shared_lock & operator= (shared_lock &&__sl) noexceptβ move assignment, takesshared_lock &&__sl, returns ashared_lock &, markednoexcept.shared_lock & operator= (shared_lock const &)=deleteβ copy assignment is deleted too. Same rule as before: not a thing. πbool owns_lock () const noexceptβ returnsbool,const noexcept. Yes or no, that's the range.mutex_type * release () noexceptβ returnsmutex_type *,noexcept. Releases and hands you back a pointer.void swap (shared_lock &__u) noexceptβ takes ashared_lock &named__u, returnsvoid,noexcept. Swap szn. πbool try_lock ()β returnsbool, takes nothing.template<typename _Rep, typename _Period> bool try_lock_for (const chrono::duration< _Rep, _Period > &__rel_time)β template, returnsbool, takes achrono::duration< _Rep, _Period >reference called__rel_time.template<typename _Clock, typename _Duration> bool try_lock_until (const chrono::time_point< _Clock, _Duration > &__abs_time)β template, returnsbool, takes achrono::time_point< _Clock, _Duration >reference named__abs_time. Theuntiltwin to theforone above. βvoid unlock ()β returnsvoid, takes nothing. That's the closer. Periodt.
π₯ Detailed Description π₯
template<typename _Mutex>
class std::shared_lock< _Mutex >"shared_lock
That's the class, written out exactly as the page has it β stray lil quote mark and all, we don't question it, we just respect it. π§
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
And that's the whole page, bestie π₯° this one came from libstdc++ (that's the source/version stamp on the footer, alongside the std::share...< _Mutex >(3) title up top). No date on the footer, so no date from me β I'm not out here making things up. Go forth and lock responsibly. ππΈ
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms