std::shared_timed_mutex(3cxx)

πŸ’… std::shared_timed_mutex πŸ’…

okay bestie, welcome to the 3cxx manual page for std::shared_timed_mutex β€” yes that's the libstdc++ section, we're in the C++ girlie corner of the manual now, stay with me 🫢

✨ NAME ✨

std::shared_timed_mutex β€” literally the standard shared timed mutex type. that's it, that's the whole vibe. no cap. πŸ‘‘

🌸 SYNOPSIS 🌸

#include <shared_mutex>

and plot twist, it inherits __shared_timed_mutex_base. family tree matters, iykyk 🧚

πŸŽ€ Public Member Functions πŸŽ€

  • shared_timed_mutex (const shared_timed_mutex &)=delete β€” nope, not copyable, the copy constructor is deleted, she does not do duplicates πŸ’€
  • void lock () β€” grabs the lock, iconic blocking behaviour ✨
  • void lock_shared () β€” grabs it in shared mode, so multiple besties can hold it at once 🌸
  • shared_timed_mutex & operator= (const shared_timed_mutex &)=delete β€” assignment is also deleted, no hand-me-downs, periodt πŸ™ˆ
  • bool try_lock () β€” tries to lock, returns a bool instead of just waiting forever, main character energy πŸ’…
  • template<typename _Rep , typename _Period > bool try_lock_for (const chrono::duration< _Rep, _Period > &__rtime) β€” try to lock but only for a chrono::duration you name as __rtime, returns bool ⏳
  • bool try_lock_shared () β€” same try energy but in shared mode, returns bool πŸ”₯
  • template<typename _Rep , typename _Period > bool try_lock_shared_for (const chrono::duration< _Rep, _Period > &__rtime) β€” shared + timed attempt with that chrono::duration< _Rep, _Period > &__rtime, returns bool πŸ¦‹
  • template<typename _Clock , typename _Duration > bool try_lock_shared_until (const chrono::time_point< _Clock, _Duration > &__abs_time) β€” shared attempt that runs until an absolute chrono::time_point< _Clock, _Duration > &__abs_time, returns bool ⭐
  • template<typename _Clock , typename _Duration > bool try_lock_until (const chrono::time_point< _Clock, _Duration > &__abs_time) β€” the exclusive version of the until-attempt, takes const chrono::time_point< _Clock, _Duration > &__abs_time, returns bool 🌈
  • void unlock () β€” releases the lock, go off πŸ‘‘
  • void unlock_shared () β€” releases the shared lock, ty bestie 🫢

πŸ’œ Detailed Description πŸ’œ

The standard shared timed mutex type. that's the summary, she said what she said ✨

🌟 Author 🌟

Generated automatically by Doxygen for libstdc++ from the source code. so like, the docs are literally auto-generated, not me writing them by hand, ngl πŸ€–


lowkey a reminder: everything up there is copied verbatim from the original page β€” the =deletes stay deleted, the templates stay templated, and none of the bool return values got dropped πŸ’–

okay and finally, the cute little sign-off: this whole page is brought to you by libstdc++ in section 3cxx of the manual, exactly where the footer put it. slay, go write some thread-safe code, bestie πŸ’…πŸŽ€

πŸ“¦ where this page comes from