title: What does mutex lock fail with invalid argument mean?
body: <p>This code is called in my main process and compiles fine, but when executed always throws the error below. </p>
  
  <pre><code>bounded_buffer&lt;MyData&gt; bb(200);
  Producer&lt;bounded_buffer&lt;MyData&gt; &gt; producer(&amp;bb);
  
  boost::thread produce(producer); // throws on this line
  </code></pre>
  
  <p>Here is the error that always appears when executing.</p>
  
  <pre><code>terminate called after throwing an instance of 'boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::lock_error&gt; &gt;'  
  what():  boost: mutex lock failed in pthread_mutex_lock: Invalid argument
  </code></pre>
  
  <p>The code for 'class bounded_buffer' is exactly as shown on this boost example page ... <a href="http://www.boost.org/doc/libs/1_55_0/libs/circular_buffer/example/circular_buffer_bound_example.cpp" rel="noreferrer">http://www.boost.org/doc/libs/1_55_0/libs/circular_buffer/example/circular_buffer_bound_example.cpp</a></p>
  
  <p>I found this page here which seems to show the exact same thing, but I was unable to understand the answer given. <a href="https://stackoverflow.com/questions/27660519/boost-scoped-lock-failed-everytime">Boost scoped_lock failed everytime</a></p>
  
  <p>Update:<br>
  Here is what Producer::operator() currently does when the functor is called. And my intentions for what I want this thread to do.</p>
  
  <pre><code>void operator() () {
      //init();
      //read();
  
      // this line just a test
      m_container-&gt;push_front(value_type());
  
      /*Eventually will do the following:
      while (1) {
           read_from_usb_device();
           // then store data in global buffer (bb)
      }*/
  }
  </code></pre>