2 ms·
Sometimes std::lock [1] is a solution: "Locks the given Lockable objects lock1, lock2, ..., lockn using a deadlock avoidance algorithm to avoid deadlock." Of c
by gpderetta 7y ago
Sometimes std::lock [1] is a solution: "Locks the given Lockable objects lock1, lock2, ..., lockn using a deadlock avoidance algorithm to avoid deadlock."
Of course this only work if all locks you need to take are exposed and not hidden behind some abstraction. Then again, when they are it is hard to make sure you only take one lock at a time anyway...
[1] https://en.cppreference.com/w/cpp/thread/lock https://en.cppreference.com/w/cpp/thread/lock