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


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

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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


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