• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ thread::Condition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中thread::Condition的典型用法代码示例。如果您正苦于以下问题:C++ Condition类的具体用法?C++ Condition怎么用?C++ Condition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: reinit

 // Called after a fork(), when we know we're alone again, to get
 // everything back in the proper order.
 void reinit() {
   mutex_.init();
   waiting_to_stop_.init();
   waiting_to_run_.init();
   pending_threads_ = 1;
   should_stop_ = false;
 }
开发者ID:vasco,项目名称:rubinius,代码行数:9,代码来源:shared_state.cpp


示例2: wait_to_run

    void wait_to_run() {
      pending_threads_--;
      waiting_to_stop_.signal();

      while(should_stop_) {
        waiting_to_run_.wait(mutex_);
      }

      pending_threads_++;
    }
开发者ID:vasco,项目名称:rubinius,代码行数:10,代码来源:shared_state.cpp


示例3: become_dependent

    void become_dependent(THREAD) {
      thread::Mutex::LockGuard guard(mutex_);

      switch(state->run_state()) {
      case ManagedThread::eAlone:
        // Running alone, ignore.
        return;
      case ManagedThread::eRunning:
        // Ignore this, a running thread is already dependent.
        return;
      case ManagedThread::eSuspended:
        // Again, bad, don't allow this.
        rubinius::bug("Trying to make a suspended thread dependent");
        break;
      case ManagedThread::eIndependent:
        // If the GC is running, wait here...
        while(should_stop_) {
          waiting_to_run_.wait(mutex_);
        }

        // Ok, we're running again.
        state->run_state_ = ManagedThread::eRunning;
        pending_threads_++;
      }
    }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:25,代码来源:world_state.hpp


示例4: wait_til_alone

    void wait_til_alone(THREAD) {
      thread::Mutex::LockGuard guard(mutex_);
      should_stop_ = true;

      if(cDebugThreading) {
        std::cerr << "[" << VM::current() << " WORLD waiting until alone]\n";
      }

      if(state->run_state_ != ManagedThread::eRunning) {
        rubinius::bug("A non-running thread is trying to wait till alone");
      }

      // For ourself..
      pending_threads_--;

      timer::Running<> timer(time_waiting_);

      while(pending_threads_ > 0) {
        if(cDebugThreading) {
          std::cerr << "[" << VM::current() << " WORLD waiting on condvar: "
                    << pending_threads_ << "]\n";
        }
        waiting_to_stop_.wait(mutex_);
      }

      state->run_state_ = ManagedThread::eAlone;

      if(cDebugThreading) {
        std::cerr << "[" << VM::current() << " WORLD o/~ I think we're alone now.. o/~]\n";
      }
    }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:31,代码来源:world_state.hpp


示例5: unpark

    void unpark() {
      thread::Mutex::LockGuard lg(mutex_);
      if(!sleeping_) return;

      wake_ = true;
      cond_.signal();
    }
开发者ID:Erreon,项目名称:rubinius,代码行数:7,代码来源:park.hpp


示例6: become_dependent

    void become_dependent() {
      thread::Mutex::LockGuard guard(mutex_);

      // If the GC is running, wait here...
      while(should_stop_) {
        waiting_to_run_.wait(mutex_);
      }

      pending_threads_++;
    }
开发者ID:vasco,项目名称:rubinius,代码行数:10,代码来源:shared_state.cpp


示例7: wake_all_waiters

    void wake_all_waiters() {
      thread::Mutex::LockGuard guard(mutex_);

      should_stop_ = false;

      // For ourself..
      pending_threads_++;

      waiting_to_run_.broadcast();
    }
开发者ID:vasco,项目名称:rubinius,代码行数:10,代码来源:shared_state.cpp


示例8: wait_til_alone

    void wait_til_alone() {
      thread::Mutex::LockGuard guard(mutex_);
      should_stop_ = true;

      // For ourself..
      pending_threads_--;

      timer::Running timer(time_waiting_);

      while(pending_threads_ > 0) {
        waiting_to_stop_.wait(mutex_);
      }
    }
开发者ID:vasco,项目名称:rubinius,代码行数:13,代码来源:shared_state.cpp


示例9: wait_to_run

    void wait_to_run(THREAD) {
      if(cDebugThreading) {
        std::cerr << "[" << VM::current() << " WORLD stopping, waiting to be restarted]\n";
      }

      if(state->run_state_ != ManagedThread::eRunning) {
        rubinius::bug("Suspending a non running thread!");
      }

      state->run_state_ = ManagedThread::eSuspended;
      pending_threads_--;
      waiting_to_stop_.signal();

      while(should_stop_) {
        waiting_to_run_.wait(mutex_);
      }

      pending_threads_++;
      state->run_state_ = ManagedThread::eRunning;

      if(cDebugThreading) {
        std::cerr << "[" << VM::current() << " WORLD restarted]\n";
      }
    }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:24,代码来源:world_state.hpp


示例10: wake_all_waiters

    void wake_all_waiters(THREAD) {
      thread::Mutex::LockGuard guard(mutex_);
      should_stop_ = false;

      if(cDebugThreading) {
        std::cerr << "[" << VM::current() << " WORLD waking all threads]\n";
      }

      if(state->run_state_ != ManagedThread::eAlone) {
        rubinius::bug("A non-alone thread is trying to wake all");
      }

      // For ourself..
      pending_threads_++;

      waiting_to_run_.broadcast();

      state->run_state_ = ManagedThread::eRunning;
    }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:19,代码来源:world_state.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ thread::Mutex类代码示例发布时间:2022-05-31
下一篇:
C++ tf::Vector3类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap