title: I don't understand C++11 conditional_variable specifics on detached threads
body: <p>I have got two pieces of code running in detached threads appropriately:</p>
  
  <pre><code>{
      std::lock_guard&lt;std::mutex&gt; lck( interThreadLockMtx );
  
      //std::unique_lock&lt;std::mutex&gt; lckGiveCond( mtxCondVar );
  
      condVarGivePasswd.notify_one();
  
      std::unique_lock&lt;std::mutex&gt; lckCond( condVarTakePasswdMtx );
      condVarTakePasswd.wait( lckCond );
  
      passwd = newPasswd;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>    for (;;)
      {
          std::unique_lock&lt;decltype(mtxCondVar)&gt; mtxCondVarLock( mtxCondVar );
          condVarGivePasswd.wait( mtxCondVarLock );
          newPasswd = genNewPasswd();
          //std::unique_lock&lt;std::mutex&gt; lckCond( condVarTakePasswdMtx );
          condVarTakePasswd.notify_one();
      }
  </code></pre>
  
  <p>I run this code compiled with clang++ on Mac OS X Mavericks and it appears to me that notify_one calls have no effect since both threads remain blocked on wait condition_variable::wait calls. Does anybody have any idea on what is going wrong here?</p>
  
  <p>Here is a bit of debugging that reveals that cv's are getting blocked upon wait calls:</p>
  
  <pre><code>Process 63102 stopped
  * thread #1: tid = 0x142f17, 0x00007fff86fba716 libsystem_kernel.dylib`__psynch_cvwait + 10,     queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  thread #2: tid = 0x142f31, 0x00007fff86fba716 libsystem_kernel.dylib`__psynch_cvwait + 10
  thread #3: tid = 0x142f32, 0x00007fff86fba746 libsystem_kernel.dylib`__psynch_mutexwait + 10
  thread #4: tid = 0x142f33, 0x00007fff86fba746 libsystem_kernel.dylib`__psynch_mutexwait + 10
  thread #5: tid = 0x142f34, 0x00007fff86fba746 libsystem_kernel.dylib`__psynch_mutexwait + 10
  </code></pre>
  
  <p>It seems that I'm having race conditions here with <code>std::unique_lock&lt;std::mutex&gt;</code> that is mandatory for wait call.</p>