std::unique_lock::unlock(3)

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

πŸ’… std::unique_lock::unlock β€” the C++ Standard Library one, bestie

okay so this is std::unique_lock::unlock from the C++ Standard Library, and like β€” the name literally tells you the whole plot, but we're gonna do it properly anyway because that's the vibe around here. πŸŽ€


✨ Synopsis ✨

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

Unlocks (i.e., releases ownership of) the associated mutex and releases ownership. That's the whole thing. It's a two-for-one: the mutex gets unlocked and the unique_lock stops owning it. Slay. πŸ‘‘

std::system_error is thrown if there is no associated mutex or if the mutex is not locked.

no cap, if you call this on a lock that isn't holding anything, it's gonna yell at you. that's not me being dramatic, that's the standard. 😭

🫢 Parameters 🫢

(none) β€” she takes nothing, she needs nothing, she's low maintenance.


🌸 Return value 🌸

(none) β€” she gives nothing back either. iconic of her honestly. void behavior fr fr.


πŸ”₯ Exceptions πŸ”₯

  • Any exceptions thrown by mutex()->unlock().
  • If there is no associated mutex or the mutex is not locked, std::system_error with an error code of std::errc::operation_not_permitted.
⚠️ bestie read that second bullet again. no mutex attached or mutex not locked = std::system_error with std::errc::operation_not_permitted. main character energy does not exempt you from the precondition check. πŸ’€

πŸ¦‹ Example πŸ¦‹

This section is incomplete.

Reason: no example.

not me showing up with an empty example section 😭 the authors literally left it as a todo, so we're not gonna make one up β€” that would be lying and lying is not the vibe. πŸ™ˆ


🌈 See also 🌈

  • lock β€” locks (i.e., takes ownership of) the associated mutex (public member function)
  • the other one β€” disassociates the associated mutex without unlocking (i.e., releasing ownership of) it (public member function)
iykyk: one of these takes the mutex, one of these lets the mutex go without unlocking it. very different energy. do not mix them up. 🧚

πŸ“ Category πŸ“

  • Todo no example

βœ¨πŸ’– okay that's the whole page, you ate that πŸ’–βœ¨

cute little sign-off because we're polite: this one came from cppreference.com, dated 2024.06.10, and it's std::unique_lock::unlock(3). go forth and unlock responsibly, bestie πŸ’…πŸ«Ά

πŸ“¦ where this page comes from