lock Function

Attempts to lock all arguments without deadlock.

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

Remarks

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.

Requirements

Header: mutex

Namespace: std

See Also

Reference

<mutex>

mutex Class (STL)

recursive_mutex Class

recursive_timed_mutex Class

timed_mutex Class

Other Resources

Header Files