0
Exclusive ownership of mutex
Hi I know we must be careful to use RAII and same is true for Mutex as well. But what if care was not taken. Is there any mechanism to protect by throwing compilation or run time error check for violation? In other words Mutex m; Lock_guard<mutex> l1(m); Lock_guard<mutex> l2(m); What would happen here? Undefined behaviour or deadlock ? Can we do some check to access this with assert or exceptions? Another scenario : Lock_guard<mutex> l1(m); Unique_lock<mutex> l2(m); Basically, exclusive mutex is managed by two different owners
0 ответов