Why would I use a
unique_lock<>
wrapper?
I sometimes see code like this
std::unique_lock<std::mutex> lock(m_active_sessions_guard); // lock() the associated mutex
m_active_sessions[request_id] = session;
lock.unlock();
where a unique_lock<>
is created just to lock the associated mutex.
Having searched, I've found that this class is not copyable. Is this the only benefit of using it?
Aucun commentaire:
Enregistrer un commentaire