Attempts to acquire a lock on the mutex associated with *this.
bool try_lock();
- Preconditions:
this->mutex()!=NULL,this->owns_lock()==false.- Effects:
Calls
this->mutex()->try_lock().- Returns:
trueif the call tothis->mutex()->try_lock()returnedtrue,falseotherwise.- Throws:
Any exceptions thrown by
this->mutex()->try_lock().std::system_errorwith an error code ofstd::errc::operation_not_permittedifthis->mutex()==NULL.std::system_errorwith an error code ofstd::errc::resource_deadlock_would_occurifthis->owns_lock()==trueon entry.- Postcondition:
If the function returns
true,this->owns_lock()==true, otherwisethis->owns_lock()==false.
Header
#include <mutex>