The empty class std::try_to_lock can be used to alter the behaviour of lock_guard (and other similar types), so that it doesn't block if the mutex is already locked: for example:
std::lock_guard<std::mutex> locker(mymutex, std::try_to_lock);
How is this behaviour useful? It seems that neither the state of the locker nor the mutex can be inspected to determine the lock state even though whether the locker acquired the lock is well defined.
Aucun commentaire:
Enregistrer un commentaire