std::lock(Mutexes...)
In your case, both kettle_tap()and tap_kettle()have to start with:
std::lock(tap, kettle);
but the order of the mutex arguments does not matter, so it may be different for both functions.
Lock multiple mutexes
, , .
, , try_lock unlock, , ( - ).
(, - , ), , ( ), .
, std::lock_guard:
std::lock(tap, kettle);
std::lock_guard<std::mutex> kettle_lock(kettle, std::adopt_lock);
std::lock_guard<std::mutex> tap_lock(tap, std::adopt_lock);