title: Why is Boost scoped_lock not unlocking the mutex?
body: <p>I've been using <code>boost::mutex::scoped_lock</code> in this manner:</p>
  
  <pre><code>void ClassName::FunctionName()
  {
      {  
       boost::mutex::scoped_lock scopedLock(mutex_);
       //do stuff
        waitBoolean=true;
      }
      while(waitBoolean == true ){
          sleep(1);
      }
      //get on with the thread's activities
  }
  </code></pre>
  
  <p>Basically it sets waitBoolean, and the other thread signals that it is done by setting waitBoolean to false; </p>
  
  <p>This doesn't seem to work, however, because the other thread can't get a lock on mutex_ !!</p>
  
  <p>I was assuming that by wrapping the scoped_lock in brackets I would be terminating its lock.  This isn't the case?  Reading online says that it only gives up the mutex when the destructor is called.  Won't it be destroyed when it goes out of that local scope?</p>
  
  <p>Signaling part of code:</p>
  
  <pre><code>while(running_){
     boost::mutex::scoped_lock scopedLock(mutex_);
     //Run some function that need to be done...
     if(waitBoolean){
        waitBoolean=false;
     }
  }
  </code></pre>
  
  <p>Thanks!</p>