in cpp/acs_agent_client.cc [498:523]
void AcsAgentClient::Shutdown() {
if (read_response_thread_.joinable()) {
{
// Wakes up ClientReadMessage() to shut it down.
absl::MutexLock lock(&response_read_mtx_);
client_read_state_ = ClientState::kShutdown;
}
read_response_thread_.join();
}
// Shutdown the restart_client_thread_ before the RPC is terminated.
// Otherwise, the restart_client_thread_ may try to restart the RPC.
if (restart_client_thread_.joinable()) {
{
absl::MutexLock lock(&reactor_mtx_);
stream_state_ = ClientState::kShutdown;
}
restart_client_thread_.join();
}
{
absl::MutexLock lock(&reactor_mtx_);
if (reactor_ != nullptr) {
reactor_ = nullptr;
}
}
}