---
name: "std::unique_lock"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::unique_lock"
---

# std::unique\_lock(3)

A movable scoped lock type.

## NAME

std::unique\_lock\< \_Mutex \> - A movable scoped lock type.

## SYNOPSIS

\#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\
 Swap overload for unique\_lock objects.

## 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

## 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.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
