std::scoped_lock::scoped_lock - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::scoped_lock::scoped_lock

From cppreference.com
< cpp‎ | thread‎ | scoped lock

explicit scoped_lock( MutexTypes&... m ); | (1) | (since C++17)
scoped_lock( MutexTypes&... m, std::adopt_lock_t t ); | (2) | (since C++17)
scoped_lock( const scoped_lock& ) = delete; | (3) | (since C++17)

Acquires ownership of the given mutexes `m`.

1) If sizeof...(MutexTypes) == 0, does nothing. Otherwise, If sizeof...(MutexTypes) == 1, effectively calls m.lock(). Otherwise, effectively calls std::lock(m...). The behavior is undefined if one of `MutexTypes` is not a recursive mutex and the current thread already owns the corresponding argument in m....
2) Acquires ownership of the mutexes m... without attempting to lock any of them. The behavior is undefined unless the current thread owns all of the mutexes in `m...`.
3) Copy constructor is deleted.

The behavior is undefined if `m` is destroyed before the `scoped_lock` object is.

### [edit] Parameters

m | - | mutexes to acquire ownership of
t | - | tag parameter used to select non-locking version of the constructor

### [edit] Exceptions

1) Throws any exceptions thrown by m.lock()
2) Throws nothing
Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/thread/scoped_lock/scoped_lock&oldid=91197"