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 to mutex_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 an adopt_lock_t tag riding along. 🫢
  • template<typename _Rep, typename _Period> shared_lock (mutex_type &__m, const chrono::duration< _Rep, _Period > &__rel_time) β€” template constructor: your __m plus a chrono::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: __m plus a chrono::time_point< _Clock, _Duration > reference named __abs_time. πŸ”₯
  • shared_lock (mutex_type &__m, defer_lock_t) noexcept β€” __m plus a defer_lock_t tag, and it's marked noexcept so it's promising not to throw. πŸ’…
  • shared_lock (mutex_type &__m, try_to_lock_t) β€” __m plus a try_to_lock_t tag. No noexcept on this one, just saying. πŸ‘€
  • shared_lock (shared_lock &&__sl) noexcept β€” move constructor, takes shared_lock &&__sl, and it's noexcept. 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 () β€” returns void, takes nothing. It's just lock().
  • mutex_type * mutex () const noexcept β€” returns a mutex_type *, and it's const 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, takes shared_lock &&__sl, returns a shared_lock &, marked noexcept.
  • shared_lock & operator= (shared_lock const &)=delete β€” copy assignment is deleted too. Same rule as before: not a thing. πŸ™ˆ
  • bool owns_lock () const noexcept β€” returns bool, const noexcept. Yes or no, that's the range.
  • mutex_type * release () noexcept β€” returns mutex_type *, noexcept. Releases and hands you back a pointer.
  • void swap (shared_lock &__u) noexcept β€” takes a shared_lock & named __u, returns void, noexcept. Swap szn. 🌈
  • bool try_lock () β€” returns bool, takes nothing.
  • template<typename _Rep, typename _Period> bool try_lock_for (const chrono::duration< _Rep, _Period > &__rel_time) β€” template, returns bool, takes a chrono::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, returns bool, takes a chrono::time_point< _Clock, _Duration > reference named __abs_time. The until twin to the for one above. ⭐
  • void unlock () β€” returns void, 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