Documentation Home >> Headers >> <mutex> Header >> std::unique_lock >> std::unique_lock::lock Member Function

Acquires a lock on the mutex associated with *this.

void lock();

Preconditions:

this->mutex()!=NULL, this->owns_lock()==false.

Effects:

Calls this->mutex()->lock().

Throws:

Any exceptions thrown by this->mutex()->lock(). std::system_error with an error code of std::errc::operation_not_permitted if this->mutex()==NULL. std::system_error with an error code of std::errc::resource_deadlock_would_occur if this->owns_lock()==true on entry.

Postcondition:

this->owns_lock()==true.

Header

#include <mutex>

See Also