std::scoped_lock (C++17)
suggest changestd::scoped_lock provides RAII style semantics for owning one or more mutexes, combined with the lock avoidance algorithms used by std::lock. When std::scoped_lock is destroyed, each owned mutex is unlocked. The standard does not require that unlock to happen in the reverse order of acquisition.
{
std::scoped_lock lock{_mutex1,_mutex2};
//do something
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents