title: what if notify() is called before wait()?
body: <p>I have a situation where a notify() 'can' be called before a wait(). </p>
  
  <p>I am trying to make a simulator to schedule its next event when I 'notify' him by sending him messages. So I have devised a wait->notify->scedule chain</p>
  
  <pre><code>void Broker::pause()
  {
      boost::unique_lock&lt;boost::mutex&gt; lock(m_pause_mutex);
      {
          std::cout &lt;&lt; "pausing the simulation" &lt;&lt; std::endl;
          m_cond_cnn.wait(lock);
          std::cout &lt;&lt; "Simulation UNpaused" &lt;&lt; std::endl;
          // the following line causes the current function to be called at 
          // a later time, and a notify() can happen before the current function
          // is called again
          Simulator::Schedule(MilliSeconds(xxx), &amp;Broker::pause, this);
      }
  }
  
  void Broker::messageReceiveCallback(std::string message) {
      boost::unique_lock&lt;boost::mutex&gt; lock(m_pause_mutex);
      {
          m_cond_cnn.notify_one();
      }
  }
  </code></pre>
  
  <p>the problem here is that: there can be situations that a notify() is called before its wait() is called.</p>
  
  <p>Is there a solution for such situation?
  thank you</p>