unique_lock::lock Method

Blocks the calling thread until the thread obtains ownership of the associated mutex.

void lock();

Remarks

If the stored mutex pointer is null, this method throws a system_error that has an error code of operation_not_permitted.

If the calling thread already owns the associated mutex, this method throws a system_error that has an error code of resource_deadlock_would_occur.

Otherwise, this method calls lock on the associated mutex and sets the internal thread ownership flag to true.

Requirements

Header: mutex

Namespace: std

See Also

Reference

unique_lock Class

<mutex>