Namespaces
Variants
Views
Actions

std::lock_guard::lock_guard

From cppreference.com
< cpp‎ | thread‎ | lock guard
Revision as of 19:44, 2 November 2012 by P12bot (Talk | contribs)

Template:ddcl list begin <tr class="t-dcl ">

<td >
explicit lock_guard( mutex_type& m );
</td>

<td > (1) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">

<td >
lock_guard( mutex_type& m, std::adopt_lock_t t );
</td>

<td > (2) </td> <td > (since C++11) </td> </tr> Template:ddcl list end

Acquires ownership of the given mutex m.

1) If m is not a recursive mutex, requires that the current thread does not own m. Effectively calls m.lock().

2) Requires that the current thread owns m.

The behavior is undefined if m is destroyed before the lock_guard object is.

Parameters

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