当前位置: 首页>>代码示例>>C++>>正文


C++ conditional::wait方法代码示例

本文整理汇总了C++中conditional::wait方法的典型用法代码示例。如果您正苦于以下问题:C++ conditional::wait方法的具体用法?C++ conditional::wait怎么用?C++ conditional::wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在conditional的用法示例。


在下文中一共展示了conditional::wait方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int perthreadtestApp::main (void)
{
	outputOne = outputTwo = outputThree = 0;
	__THREADED = true;
	testThread one (&outputOne, 18321);
	testThread two (&outputTwo, 33510);
	testThread three (&outputThree, 18495);
	
	one.sendevent ("shutdown");
	two.sendevent ("shutdown");
	three.sendevent ("shutdown");
	
	threadStopped.wait ();
	::printf ("%i %i %i\n", outputOne, outputTwo, outputThree);
	threadStopped.wait ();
	::printf ("%i %i %i\n", outputOne, outputTwo, outputThree);
	threadStopped.wait ();
	::printf ("%i %i %i\n", outputOne, outputTwo, outputThree);
	
	value out;
	out.newval() = outputOne;
	out.newval() = outputTwo;
	out.newval() = outputThree;
	
	out.savexml ("out.xml");
	return 0;
}
开发者ID:CloudVPS,项目名称:openpanel-grace,代码行数:27,代码来源:main.cpp

示例2: wait

 inline void wait() const {
   mut.lock();
   waitercount++;
   while (semvalue == 0) {
     cond.wait(mut);
   }
   waitercount--;
   semvalue--;
   mut.unlock();
 }
开发者ID:greeness,项目名称:graphlab_CMU,代码行数:10,代码来源:pthread_tools.hpp

示例3: wait_until_empty

 /**
  * The conceptual "reverse" of dequeue().
  * This function will block until the queue becomes empty, or 
  * until stop_blocking() is called.
  * Returns true on success. 
  * Returns false if the queue is no longer alive
 */
 bool wait_until_empty() {
   m_mutex.lock();
   // if the queue still has elements in it while I am still alive, wait
   while (m_queue.empty() == false && m_alive == true) {
     sleeping_on_empty++;
     m_empty_conditional.wait(m_mutex);
     sleeping_on_empty--;
   }
   m_mutex.unlock();
   // if I am alive, the queue must be empty. i.e. success
   // otherwise I am dead
   return m_alive;
 }
开发者ID:3upperm2n,项目名称:PowerGraph,代码行数:20,代码来源:blocking_queue.hpp

示例4: wait_for_data

    inline bool wait_for_data() {

      m_mutex.lock();
      bool success = false;
      // Wait while the queue is empty and this queue is alive
      while(m_queue.empty() && m_alive) {
        sleeping++;
        m_conditional.wait(m_mutex);
        sleeping--;
      }
      // An element has been added or a signal was raised
      if(!m_queue.empty()) {
        success = true;
      } 
      m_mutex.unlock();

      return success; 
    }
开发者ID:3upperm2n,项目名称:PowerGraph,代码行数:18,代码来源:blocking_queue.hpp

示例5: make_pair

 inline std::pair<T, bool> dequeue_and_begin_critical_section_on_success() {
   m_mutex.lock();
   T elem = T();
   bool success = false;
   // Wait while the queue is empty and this queue is alive
   while(m_queue.empty() && m_alive) {
     sleeping++;
     m_conditional.wait(m_mutex);
     sleeping--;
   }
   // An element has been added or a signal was raised
   if(!m_queue.empty()) {
     success = true;
     elem = m_queue.front();
     m_queue.pop_front();
     if (m_queue.empty() && sleeping_on_empty) {
       m_empty_conditional.signal();
     }
   }
   if (!success) m_mutex.unlock(); 
   return std::make_pair(elem, success);
 }
开发者ID:3upperm2n,项目名称:PowerGraph,代码行数:22,代码来源:blocking_queue.hpp

示例6: wait

 /**
  * Waits for all replies to complete. It is up to the 
  * reply implementation to decrement the counter.
  */
 inline void wait() {
   mut.lock();
   while(!valready) cond.wait(mut);
   mut.unlock();
 }
开发者ID:3upperm2n,项目名称:PowerGraph,代码行数:9,代码来源:request_reply_handler.hpp


注:本文中的conditional::wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。