I have 2 processes which share a queue which is synchronized by a mutex and conditions. I have the following code in one of my processes.
named_mutex mutex(open_only, "MyMutex");
int main()
{
while(1)
{
scoped_lock <named_mutex> lock(mutex)
//do some processing
}
}
My question is whether the mutex has scope throughout all calls in the while loop or does it need to be acquired each time the while loop starts? What is the scope of the mutex for it to be unlocked? It seems each time at the end of the while loop the mutex is unlocked.
Thanks