The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

lock Function


Attempts to lock all arguments without deadlock.

template<class L1, class L2, class... L3>
   void lock(L1&, L2&, L3&...);

The arguments to the template function must be mutex types, except that calls to try_lock might throw exceptions.

The function locks all of its arguments without deadlock by calls to lock, try_lock, and unlock. If a call to lock or try_lock throws an exception, the function calls unlock on any of the mutex objects that were successfully locked before rethrowing the exception.


Header: mutex

Namespace: std