Example #1
0
    // If called when the GC is waiting to run,
    //   wait until the GC tells us it's ok to continue.
    // always increments pending_threads_ at the end.
    void become_independent() {
      thread::Mutex::LockGuard guard(mutex_);

      // If someone is waiting on us to stop, stop now.
      if(should_stop_) wait_to_run();
      pending_threads_--;
    }
Example #2
0
 void checkpoint() {
   // Test should_stop_ without the lock, because we do this a lot.
   if(should_stop_) {
     thread::Mutex::LockGuard guard(mutex_);
     wait_to_run();
   }
 }
Example #3
0
    /**
     * If called when the GC is waiting to run, wait until the GC tells us its
     * OK to continue. Always decrements pending_threads_ at the end.
     */
    void become_independent(THREAD) {
      thread::Mutex::LockGuard guard(mutex_);

      switch(state->run_state()) {
      case ManagedThread::eAlone:
        // Running alone, ignore.
        return;
      case ManagedThread::eIndependent:
        // Already independent, ignore.
        return;
      case ManagedThread::eSuspended:
        // This is sort of bad. We're already suspended
        // and want to go independent. Abort on this.
        rubinius::bug("Trying to make a suspended thread independent");
        break;
      case ManagedThread::eRunning:
        // If someone is waiting on us to stop, stop now.
        if(should_stop_) wait_to_run(state);

        // We're now independent.
        state->run_state_ = ManagedThread::eIndependent;
        pending_threads_--;
        break;
      }
    }
Example #4
0
    bool checkpoint(THREAD) {
      // Test should_stop_ without the lock, because we do this a lot.
      if(should_stop_) {
        // If the thread is set to alone, then ignore checkpointing
        if(state->run_state() == ManagedThread::eAlone) return false;
        wait_to_run(state);
        return true;
      }

      return false;
    }