std::recurs...tex::unlock(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… NAME πŸ’…

std::recursive_timed_mutex::unlock β€” literally the unlock function of std::recursive_timed_mutex, no cap

okay bestie, so this one is short but she's important, so pay attention πŸŽ€


✨ Synopsis ✨

void unlock();  (since C++11)

So here's the vibe 🌸: this bad girl unlocks the mutex if its level of ownership is 1. And what does that mean? It means there was exactly one more call to lock() than there were calls to unlock() made by this thread. Otherwise, she just reduces the level of ownership by 1. Cute, right? Recursive icon behavior πŸ’…

🚨 Vibe check, and this one is serious: the mutex must be locked by the current thread of execution. If it's not? The behavior is undefined. Like, undefined undefined. Not a little undefined. Do not test her πŸ™ˆ

And the slay part: this operation synchronizes-with (as defined in std::memory_order) any subsequent lock operation that obtains ownership of the same mutex. Periodt. ⭐


🫢 Parameters 🫢

(none)

Nothing! Zero. Empty. She takes no arguments, she's low maintenance like that πŸ’–


πŸŽ€ Return value πŸŽ€

(none)

She returns nothing because she's already given you everything (the unlocked mutex) πŸ’€


πŸ¦‹ Exceptions πŸ¦‹

Throws nothing. Not a single thing. Not one exception. She's not dramatic like that 🌈


πŸ‘‘ Notes πŸ‘‘

Real talk πŸ”₯: unlock() is usually not called directly. Instead, std::unique_lock and std::lock_guard are used to manage exclusive locking. Those two are the main characters here, and unlock() is just out here doing supporting role energy. iykyk 😭


πŸ’œ Example πŸ’œ

This section is incomplete
Reason: no example

Yeah bestie, there's literally no example. The docs said "not today" πŸ™ˆ


🌸 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)
  • try_lock_for β€” tries to lock the mutex, returns if the mutex has been unavailable for the specified timeout duration (public member function)
  • try_lock_until β€” tries to lock the mutex, returns if the mutex has been unavailable until specified time point has been reached (public member function)
  • C documentation for mtx_unlock

Category: Todo no example πŸ“ (the to-do list remains untouched, iconic honestly)


and that's the whole page, bestie 🧚✨ she's from cppreference.com, dated 2024.06.10 β€” the std::recurs...tex::unlock(3) era. go forth and unlock responsibly, mwah πŸ’‹

πŸ“¦ where this page comes from