Exemplo n.º 1
0
 /** Wakes up all threads waiting on the queue whether 
     or not an element is available. Once this function is called,
     all existing and future dequeue operations will return with failure.
     Note that there could be elements remaining in the queue after 
     stop_blocking() is called. 
 */
 inline void stop_blocking() {
   m_mutex.lock();
   m_alive = false;
   m_conditional.broadcast();
   m_empty_conditional.broadcast();
   m_mutex.unlock();
 }
Exemplo n.º 2
0
void producer::run (void)
{
	while (true)
	{
		exclusivesection (db)
		{
			db.clear ();
			for (int i=0; i<64; ++i)
			{
				statstring key = strutil::uuid ();
				string value = strutil::uuid ();
				
				db[key] = value;
			}
		}
		core.sh ("/usr/bin/true");
		value v = nextevent ();
		if (v.type() == "shutdown")
		{
			shutcond.broadcast();
			return;
		}
	}
}
Exemplo n.º 3
0
 /**
  * Causes any threads blocking on "wait_until_empty()" to wake
  * up and evaluate the state of the queue. If the queue is not empty,
  * the threads will return back to sleep immediately. If the queue
  * is empty, all threads will return.
 */
 void broadcast_blocking_empty() {
   m_mutex.lock();
   m_empty_conditional.broadcast();
   m_mutex.unlock();
 }    
Exemplo n.º 4
0
 /**
  * Causes any threads currently blocking on a dequeue to wake up
  * and evaluate the state of the queue. If the queue is empty,
  * the threads will return back to sleep immediately. If the queue
  * is destroyed through stop_blocking, all threads will return. 
  */
 void broadcast() {
   m_mutex.lock();
   m_conditional.broadcast();
   m_mutex.unlock();
 }