# Mutexes
[Concurrency]

Collaboration diagram for Mutexes:

## Classes

- struct std::adopt_lock_t
    Assume the calling thread has already obtained mutex ownership and manage it. More...
- struct std::defer_lock_t
    Do not acquire ownership of the mutex. More...
- class std::lock_error
    Thrown to indicate errors with lock operations. More...
- class std::lock_guard< _Mutex >
    Scoped lock idiom. More...
- class std::mutex
    mutex More...
- struct std::once_flag
    once_flag More...
- class std::recursive_mutex
    recursive_mutex More...
- class std::recursive_timed_mutex
    recursive_timed_mutex More...
- class std::timed_mutex
    timed_mutex More...
- struct std::try_to_lock_t
    Try to acquire ownership of the mutex without blocking. More...
- class std::unique_lock< _Mutex >
    unique_lock More...

## Functions

- unique_lock< mutex > & std::__get_once_functor_lock ()
- void std::__once_proxy ()
- template<typename _Callable , typename... _Args> void std::call_once (once_flag &__once, _Callable __f, _Args &&...__args)
- template<typename _L1 , typename _L2 , typename... _L3> void std::lock (_L1 &, _L2 &, _L3 &...)
- template<typename _Mutex > void std::swap (unique_lock< _Mutex > &__x, unique_lock< _Mutex > &&__y)
- template<typename _Mutex > void std::swap (unique_lock< _Mutex > &&__x, unique_lock< _Mutex > &__y)
- template<typename _Mutex > void std::swap (unique_lock< _Mutex > &__x, unique_lock< _Mutex > &__y)
- template<typename _Lock1 , typename _Lock2 , typename... _Lock3> int std::try_lock (_Lock1 &__l1, _Lock2 &__l2, _Lock3 &...__l3)

## Variables

- function< void()> std::__once_functor
- const adopt_lock_t std::adopt_lock
- const defer_lock_t std::defer_lock
- const try_to_lock_t std::try_to_lock

## Detailed Description

Classes for mutex support.

## Function Documentation

template<typename _Callable , typename... _Args>

void std::call_once | ( | once_flag & | __once,
|  | _Callable | __f,
|  | _Args &&... | __args |
| ) |  |  | `[inline]`

call_once

Definition at line 741 of file mutex.

References std::once_flag::_M_once, std::bind(), std::unique_lock< _Mutex >::lock(), and std::unique_lock< _Mutex >::unlock().

template<typename _L1 , typename _L2 , typename... _L3>

void std::lock | ( | _L1 & | ,
|  | _L2 & | ,
|  | _L3 & | ... |
| ) |  |  | `[inline]`

lock

template<typename _Lock1 , typename _Lock2 , typename... _Lock3>

int std::try_lock | ( | _Lock1 & | __l1,
|  | _Lock2 & | __l2,
|  | _Lock3 &... | __l3 |
| ) |  |  | `[inline]`

Generic try_lock.

Parameters:

  | __l1 | Meets Mutex requirements (try_lock() may throw).
  | __l2 | Meets Mutex requirements (try_lock() may throw).
  | __l3 | Meets Mutex requirements (try_lock() may throw).

Returns:
  Returns -1 if all try_lock() calls return true. Otherwise returns a 0-based index corresponding to the argument that returned false.

Postcondition:
  Either all arguments are locked, or none will be.

Sequentially calls try_lock() on each argument.

Definition at line 686 of file mutex.

References std::try_lock().

Referenced by std::try_lock().