title: "unique_lock has no mutex: Operation not permitted" error when attempting to wait on boost::condition_Variable
body: <p>I'm trying to use boost::wait_condition to sleep a thread until some new data is available. My function reduces down to this:</p>
  
  <pre><code>bool Node::waitForNewData() const
  {
      boost::unique_lock&lt;boost::mutex&gt;(mWasNotifiedMutex);
      mWasNotified = false;
      while (true)
      {
          if (mWasNotified)
              return true;
          if (mThreadIsRequestedToStop)
              return false;
          mWasNotifiedWaitCondition.wait(mWasNotifiedMutex);
      }
  }
  </code></pre>
  
  <p>Boost is throwing an exception from the wait() function with the message:</p>
  
  <pre><code>boost unique_lock has no mutex: Operation not permitted
  </code></pre>
  
  <p>I'm using a function like this to notify the wait condition:</p>
  
  <pre><code>void Node::callbackNewDataArrived()
  {
      {
          boost::unique_lock&lt;boost::mutex&gt;(mHasNewInletDataMutex);
          mWasNotified = true;
      }
      mWasNotifiedWaitCondition.notify_all();
  }
  </code></pre>
  
  <p>and these declarations in the header:</p>
  
  <pre><code>class Node
  {
      // ...
      mutable bool mWasNotified;
      mutable boost::mutex mWasNotifiedMutex;
      mutable boost::condition_variable mWasNotifiedWaitCondition;
      std::atomic&lt;bool&gt; mThreadIsRequestedToStop;
  };
  </code></pre>
  
  <p>I'm building in Xcode 4.6.2 with c++11 support enabled on OSX 10.8.5. My boost libraries were built with</p>
  
  <pre><code>./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" macosx-version=10.6 linkflags="-stdlib=libc++" --prefix=/usr/local -j 10 define=BOOST_SYSTEM_NO_DEPRECATED stage release
  </code></pre>
  
  <p>and the boost libraries I'm linking to are</p>
  
  <pre><code>libboost_chrono.a
  libboost_date_time.a
  libboost_filesystem.a
  libboost_system.a
  libboost_thread.a
  </code></pre>
  
  <p>Any idea what I'm doing wrong here?</p>