title: boost scoped_lock. Will this lock?
body: <h1>solved</h1>
  <p>I changed the bfs::directory_iterator Queue to a std::string queue, and surprisingly solved the problem.</p>
  <hr/>
  <p>Hi, I have a gut feeling that i'm doing things wrong.</p>
  <p>I've implemented (or attempted to) the thread pool pattern.</p>
  <p>N threads read from a Queue, but i'm having some trouble. Here's what i got:</p>
  <pre><code>//inside a while loop
  bool isEmpty;
  bfs::directory_iterator elem;
  
  {   
      boost::mutex::scoped_lock lock(this-&gt;queue_mutex);
      isEmpty = this-&gt;input_queue.isEmpty();
  
      if (!isEmpty){
  
          elem= *(this-&gt;input_queue.pop());
      }   
      else{
          continue;
      }   
  }
  </code></pre>
  <p>Will the scoped_lock still work inside the if's body? Im starting to believe that it wont (after running many tests). If not, is there any scoped way to do this (i.e not the explicit lock unlock way)</p>
  <p>Thanks in advance.</p>
  <h1>update</h1>
  <p>The code that adds elements to the queue looks like this</p>
  <pre><code>  //launches the above code, passing a reference to mutex and queue.
     Threads threads(queue,queue_mutex);
  
      for (bfs::directory_iterator dir_it:every file in directory){
        boost::mutex::scoped_lock lock(queue_mutex);
        
        queue.push(dir_it);
      
      
      }
  </code></pre>
  <p>Im placing a cout to control the poped filename, and if I push 2 files (file1) and (file2), and use 2 threads, I get boths &quot;file2&quot;.</p>
  <pre><code>  class Threads{
      
     boost::thread::thread_group group; 
      Thread (N){
            
      //also asigns a reference to a queue and a mutex.
       for(i 1..N){ 
         //loop is posted above.
         group.add(new boost::thread(boost::bind(&amp;loop,this)));
       }
      }
   };
      
  </code></pre>