0

I have this code ,now can anyone reply s what happens to the lock in the following situation considering that cond is true:-

for (;;) {
static mutex m;
Lock lock(m);
if (cond)
break;
... 
} 

Thanks

2 Answers2

5

Assuming Lock class follows RAII principle, it will unlock the mutex.

Naveen
  • 74,600
  • 47
  • 176
  • 233
0

The RAII allows to unlock the mutex at the end of the scope.

here is another example Scooped Lock

RAB
  • 75
  • 1
  • 9