libstdc++: std::unique_lock< _Mutex > Class Template Reference

libstdc++

std::unique_lock< _Mutex > Class Template Reference
Concurrency » Mutexes

`#include <mutex>`

## Public Types
typedef _Mutex | mutex_type

## Public Member Functions
| unique_lock (const unique_lock &)=delete
| unique_lock (mutex_type &__m)
| unique_lock (mutex_type &__m, adopt_lock_t) noexcept
template<typename _Rep, typename _Period>
| unique_lock (mutex_type &__m, const chrono::duration< _Rep, _Period > &__rtime)
template<typename _Clock, typename _Duration>
| unique_lock (mutex_type &__m, const chrono::time_point< _Clock, _Duration > &__atime)
| unique_lock (mutex_type &__m, defer_lock_t) noexcept
| unique_lock (mutex_type &__m, try_to_lock_t)
| unique_lock (unique_lock &&__u) noexcept
void | lock ()
mutex_type * | mutex () const noexcept
| operator bool () const noexcept
unique_lock & | operator= (const unique_lock &)=delete
unique_lock & | operator= (unique_lock &&__u) noexcept
bool | owns_lock () const noexcept
mutex_type * | release () noexcept
void | swap (unique_lock &__u) noexcept
bool | try_lock ()
template<typename _Rep, typename _Period>
bool | try_lock_for (const chrono::duration< _Rep, _Period > &__rtime)
template<typename _Clock, typename _Duration>
bool | try_lock_until (const chrono::time_point< _Clock, _Duration > &__atime)
void | unlock ()

## Related Symbols
(Note that these are not member symbols.)
template<typename _Mutex>
void | swap (unique_lock< _Mutex > &__x, unique_lock< _Mutex > &__y) noexcept

## Detailed Description

template<typename _Mutex>
class std::unique_lock< _Mutex >

A movable scoped lock type.

A unique_lock controls mutex ownership within a scope. Ownership of the mutex can be delayed until after construction and 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.

Since
  C++11

Definition at line 62 of file unique_lock.h.

## Member Typedef Documentation

## ◆ mutex_type

template<typename _Mutex>

typedef _Mutex std::unique_lock< _Mutex >::mutex_type

Definition at line 65 of file unique_lock.h.

## Constructor & Destructor Documentation

## ◆ unique_lock() [1/8]

template<typename _Mutex>

std::unique_lock< _Mutex >::unique_lock | ( |  | ) |
| inlinenoexcept

Definition at line 67 of file unique_lock.h.

## ◆ unique_lock() [2/8]

template<typename _Mutex>

std::unique_lock< _Mutex >::unique_lock | ( | mutex_type & | __m | ) |
| inlineexplicit

Definition at line 72 of file unique_lock.h.

## ◆ unique_lock() [3/8]

template<typename _Mutex>

std::unique_lock< _Mutex >::unique_lock | ( | mutex_type & | __m,
|  | defer_lock_t | )
| inlinenoexcept

Definition at line 79 of file unique_lock.h.

## ◆ unique_lock() [4/8]

template<typename _Mutex>

std::unique_lock< _Mutex >::unique_lock | ( | mutex_type & | __m,
|  | try_to_lock_t | )
| inline

Definition at line 84 of file unique_lock.h.

## ◆ unique_lock() [5/8]

template<typename _Mutex>

std::unique_lock< _Mutex >::unique_lock | ( | mutex_type & | __m,
|  | adopt_lock_t | )
| inlinenoexcept

Definition at line 89 of file unique_lock.h.

## ◆ unique_lock() [6/8]

template<typename _Mutex>
template<typename _Clock, typename _Duration>

std::unique_lock< _Mutex >::unique_lock | ( | mutex_type & | __m,
|  | const chrono::time_point< _Clock, _Duration > & | __atime )
| inline

Definition at line 97 of file unique_lock.h.

## ◆ unique_lock() [7/8]

template<typename _Mutex>
template<typename _Rep, typename _Period>

std::unique_lock< _Mutex >::unique_lock | ( | mutex_type & | __m,
|  | const chrono::duration< _Rep, _Period > & | __rtime )
| inline

Definition at line 105 of file unique_lock.h.

## ◆ ~unique_lock()

template<typename _Mutex>

std::unique_lock< _Mutex >::~unique_lock | ( |  | ) |
| inline

Definition at line 111 of file unique_lock.h.

## ◆ unique_lock() [8/8]

template<typename _Mutex>

std::unique_lock< _Mutex >::unique_lock | ( | unique_lock< _Mutex > && | __u | ) |
| inlinenoexcept

Definition at line 120 of file unique_lock.h.

## Member Function Documentation

## ◆ lock()

template<typename _Mutex>

void std::unique_lock< _Mutex >::lock | ( |  | ) |
| inline

Definition at line 136 of file unique_lock.h.

## ◆ mutex()

template<typename _Mutex>

mutex_type * std::unique_lock< _Mutex >::mutex | ( |  | ) | const
| inlinenodiscardnoexcept

Definition at line 234 of file unique_lock.h.

## ◆ operator bool()

template<typename _Mutex>

std::unique_lock< _Mutex >::operator bool | ( |  | ) | const
| inlineexplicitnoexcept

Definition at line 229 of file unique_lock.h.

## ◆ operator=()

template<typename _Mutex>

unique_lock & std::unique_lock< _Mutex >::operator= | ( | unique_lock< _Mutex > && | __u | ) |
| inlinenoexcept

Definition at line 127 of file unique_lock.h.

## ◆ owns_lock()

template<typename _Mutex>

bool std::unique_lock< _Mutex >::owns_lock | ( |  | ) | const
| inlinenodiscardnoexcept

Definition at line 226 of file unique_lock.h.

## ◆ release()

template<typename _Mutex>

mutex_type * std::unique_lock< _Mutex >::release | ( |  | ) |
| inlinenoexcept

Definition at line 216 of file unique_lock.h.

## ◆ swap()

template<typename _Mutex>

void std::unique_lock< _Mutex >::swap | ( | unique_lock< _Mutex > & | __u | ) |
| inlinenoexcept

Definition at line 209 of file unique_lock.h.

## ◆ try_lock()

template<typename _Mutex>

bool std::unique_lock< _Mutex >::try_lock | ( |  | ) |
| inlinenodiscard

Definition at line 151 of file unique_lock.h.

## ◆ try_lock_for()

template<typename _Mutex>
template<typename _Rep, typename _Period>

bool std::unique_lock< _Mutex >::try_lock_for | ( | const chrono::duration< _Rep, _Period > & | __rtime | ) |
| inlinenodiscard

Definition at line 183 of file unique_lock.h.

## ◆ try_lock_until()

template<typename _Mutex>
template<typename _Clock, typename _Duration>

bool std::unique_lock< _Mutex >::try_lock_until | ( | const chrono::time_point< _Clock, _Duration > & | __atime | ) |
| inlinenodiscard

Definition at line 167 of file unique_lock.h.

## ◆ unlock()

template<typename _Mutex>

void std::unique_lock< _Mutex >::unlock | ( |  | ) |
| inline

Definition at line 197 of file unique_lock.h.

## Friends And Related Symbol Documentation

## ◆ swap()

template<typename _Mutex>

void swap | ( | unique_lock< _Mutex > & | __x,
|  | unique_lock< _Mutex > & | __y )
| related

Swap overload for unique_lock objects.

Definition at line 246 of file unique_lock.h.

The documentation for this class was generated from the following file:

- unique_lock.h