zircon/kernel/object/process_dispatcher.cc
// This is called within thread T's context when it is exiting.
This is called within thread T's context when it is exiting.
This is called within thread T ' s context when it is exiting .
void ProcessDispatcher::RemoveThread(ThreadDispatcher* t) {
  LTRACE_ENTRY_OBJ;
  bool became_dead = false;
  {
    Guard<Mutex> guard{get_lock()};
    DEBUG_ASSERT(t != nullptr);
    thread_list_.erase(*t);
    if (thread_list_.is_empty()) {
      LTRACEF("last thread left the process %p, entering DEAD state\n", this);
      SetStateLocked(State::DEAD);
      became_dead = true;
    }
    Thread::RuntimeStats child_runtime;
    if (t->GetRuntimeStats(&child_runtime) == ZX_OK) {
      aggregated_runtime_stats_.Add(child_runtime.TotalRuntime());
    }
  }
  if (became_dead)
    FinishDeadTransition();
}
void ProcessDispatcher :: RemoveThread ( ThreadDispatcher * t ) { LTRACE_ENTRY_OBJ ; bool became_dead = false ; { Guard < Mutex > guard { get_lock ( ) } ; DEBUG_ASSERT ( t != nullptr ) ; thread_list_ . erase ( * t ) ; if ( thread_list_ . is_empty ( ) ) { LTRACEF ( " \n " , this ) ; SetStateLocked ( State :: DEAD ) ; became_dead = true ; } Thread :: RuntimeStats child_runtime ; if ( t -> GetRuntimeStats ( & child_runtime ) == ZX_OK ) { aggregated_runtime_stats_ . Add ( child_runtime . TotalRuntime ( ) ) ; } } if ( became_dead ) FinishDeadTransition ( ) ; }
This is called within thread T's context when it is exiting.
This is called within thread T ' s context when it is exiting .
// ZX-880: Call RemoveChildProcess outside of |get_lock()|. // we're going to check for state and possibly transition below // remove the thread from our list // if this was the last thread, transition directly to DEAD state