title: boost scoped_lock on mutex in while(1) loop
body: <p>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.</p>
  
  <pre><code>named_mutex mutex(open_only, "MyMutex");
  
  int main()
  {
     while(1)
     {
        scoped_lock &lt;named_mutex&gt; lock(mutex)
        //do some processing 
     }
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>Thanks</p>