Merge pull request #20807 from grpc/revert-20376-master

Revert "c++ check if workerthread could be spawned"
pull/20808/head
Vijay Pai 5 years ago committed by GitHub
commit 7c306debb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/cpp/thread_manager/thread_manager.cc
  2. 3
      src/cpp/thread_manager/thread_manager.h

@ -34,12 +34,8 @@ ThreadManager::WorkerThread::WorkerThread(ThreadManager* thd_mgr)
thd_ = grpc_core::Thread(
"grpcpp_sync_server",
[](void* th) { static_cast<ThreadManager::WorkerThread*>(th)->Run(); },
this, &created_);
if (!created_) {
gpr_log(GPR_ERROR, "Could not create grpc_sync_server worker-thread");
} else {
thd_.Start();
}
this);
thd_.Start();
}
void ThreadManager::WorkerThread::Run() {
@ -181,12 +177,7 @@ void ThreadManager::MainWorkLoop() {
}
// Drop lock before spawning thread to avoid contention
lock.Unlock();
WorkerThread* w = new WorkerThread(this);
if (!w->created()) {
num_pollers_--;
num_threads_--;
resource_exhausted = true;
}
new WorkerThread(this);
} else if (num_pollers_ > 0) {
// There is still at least some thread polling, so we can go on
// even though we are below the number of pollers that we would

@ -124,8 +124,6 @@ class ThreadManager {
WorkerThread(ThreadManager* thd_mgr);
~WorkerThread();
bool created() const { return created_; }
private:
// Calls thd_mgr_->MainWorkLoop() and once that completes, calls
// thd_mgr_>MarkAsCompleted(this) to mark the thread as completed
@ -133,7 +131,6 @@ class ThreadManager {
ThreadManager* const thd_mgr_;
grpc_core::Thread thd_;
bool created_;
};
// The main function in ThreadManager

Loading…
Cancel
Save