title: Difference between Boost and Pthread condition variables
body: <p>I found some code using boost threads, mutexes and condition variables but I wanna try to rewrite this code with posix threads.</p>
  
  <p>This is the Boost code, I´ve found <a href="http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html" rel="nofollow">here</a>:</p>
  
  <pre><code>void push(Data const&amp; data)
  {
      boost::mutex::scoped_lock lock(the_mutex);
      the_queue.push(data);
      lock.unlock();
      the_condition_variable.notify_one();
  }
  </code></pre>
  
  <p>In my code using pthreads I am not sure if I´m using the condition variables the right way because I am not sure if notify_one() and singalling the variables is the same:</p>
  
  <pre><code>void push(T const&amp; data)
  {
      pthread_mutex_lock(&amp;m_mutex);
      m_queue.push(data);
      pthread_mutex_unlock(&amp;m_mutex);
      pthread_cond_signal(&amp;m_condition);
  }
  </code></pre>
  
  <p>Initializing is done right before like that:</p>
  
  <pre><code>pthread_mutex_t m_mutex = PTHREAD_MUTEX_INITIALIZER;
  pthread_cond_t m_condition = PTHREAD_COND_INITIALIZER;
  </code></pre>
  
  <p>At another point they are using <code>the_condition_variable.wait(lock);</code> ... this line I would rewrite with pthreads like that: <code>pthread_cond_wait( &amp;m_condition, &amp;m_mutex);</code></p>
  
  <p>Am I on the right track?</p>