Код: Выделить всё
void somefunction
{
std::lock_guard guard(mutex1);
variable1++;
std::lock_guard guard(mutex2); //what if I took this mutex out?
variable2++;
/*
long block of code
*/
variable3++;
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... lock-guard