STD::UNIQUE_LOCK(3)
β¨ NAME β¨
std::unique_lock< _Mutex > β A movable scoped lock type. π
hiii bestie, welcome to the std::unique_lock< _Mutex >(3) page from the Library Functions Manual. The header up top is literally std::uniqu...< _Mutex >(3) (truncated, iykyk) and the manual name is Library Functions Manual. This page is about a movable scoped lock type, and we are keeping every single crumb. π«Ά
π¦ SYNOPSIS π¦
#include <mutex>
π Public Types π
typedef _Mutex mutex_typeβ the one and only public type, exactly as written. periodt. π
π Public Member Functions π
okay so here is every single member function, in the exact order the original gives them. No skips, no merges, no invented lore. fr fr β¨
unique_lock (const unique_lock &)=deleteβ copy construction is deleted, so do not try it, bestie πunique_lock (mutex_type &__m)β constructor that takesmutex_type &__m.unique_lock (mutex_type &__m, adopt_lock_t) noexceptβ constructor withadopt_lock_t, and it isnoexcept.template<typename _Rep, typename _Period> unique_lock (mutex_type &__m, const chrono::duration< _Rep, _Period > &__rtime)β constructor withchrono::duration< _Rep, _Period > &__rtime.template<typename _Clock, typename _Duration> unique_lock (mutex_type &__m, const chrono::time_point< _Clock, _Duration > &__atime)β constructor withchrono::time_point< _Clock, _Duration > &__atime.unique_lock (mutex_type &__m, defer_lock_t) noexceptβ constructor withdefer_lock_t, and it isnoexcept.unique_lock (mutex_type &__m, try_to_lock_t)β constructor withtry_to_lock_t.unique_lock (unique_lock &&__u) noexceptβ move constructor, and it isnoexcept.void lock ()β member function namedlock.mutex_type * mutex () const noexceptβ returns amutex_type *, and it isconst noexcept.operator bool () const noexceptβ bool conversion operator, and it isconst noexcept.unique_lock & operator= (const unique_lock &)=deleteβ copy assignment is deleted.unique_lock & operator= (unique_lock &&__u) noexceptβ move assignment, and it isnoexcept.bool owns_lock () const noexceptβ returnsbool, and it isconst noexcept.mutex_type * release () noexceptβ returnsmutex_type *, and it isnoexcept.void swap (unique_lock &__u) noexceptβ memberswaptakingunique_lock &__u, and it isnoexcept.bool try_lock ()β returnsbool.template<typename _Rep, typename _Period> bool try_lock_for (const chrono::duration< _Rep, _Period > &__rtime)β template returningbool, takingchrono::duration< _Rep, _Period > &__rtime.template<typename _Clock, typename _Duration> bool try_lock_until (const chrono::time_point< _Clock, _Duration > &__atime)β template returningbool, takingchrono::time_point< _Clock, _Duration > &__atime.void unlock ()β member function namedunlock.
π Related Symbols π
- (Note that these are not member symbols.) the original literally says this, bestie, so it stays.
template<typename _Mutex> void swap (unique_lock< _Mutex > &__x, unique_lock< _Mutex > &__y) noexceptβ Swap overload for unique_lock objects. that description is exactly from the page.
π Detailed Description π
template<typename _Mutex>
class std::unique_lock< _Mutex >"A movable scoped lock type.
yes, there is a stray quote mark right there in the original, and I am not fixing it. we keep the details exactly. π
okay so unique_lock controls mutex ownership within a scope. Ownership of the mutex can be delayed until after construction, and it can be transferred to another unique_lock by move construction or move assignment. If a mutex lock is owned when the destructor runs, ownership will be released. that is the whole vibe, no cap.
Since:
C++11
π Friends And Related Symbol Documentation π
template<typename _Mutex> void swap (unique_lock< _Mutex > & __x, unique_lock< _Mutex > & __y) [related]
Swap overload for unique_lock objects.
ngl, this one has spaces in & __x and & __y, and it ends with [related]. The earlier Related Symbols version has &__x and &__y and noexcept. Both are real, both stay. slay. β¨
πΈ Author πΈ
Generated automatically by Doxygen for libstdc++ from the source code.
okay bye bestie π the footer at the bottom says libstdc++ and std::uniqu...< _Mutex >(3), so that is the source/version and page-name sign-off. There is no date in that footer, fr fr, so I am not inventing one. Stay iconic, stay locked, mwah π
β¨
π¦ 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