aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/thread_manager
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-04-18 13:14:45 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-04-18 13:14:45 -0700
commit35f27cd457207e6d51304a40d736dca53285e79f (patch)
treefeaf11d70e32dcb96bfb600793a8be37fda122af /src/cpp/thread_manager
parent4818150728ba9edf84231a726048763cf555a81a (diff)
More cleanup
Diffstat (limited to 'src/cpp/thread_manager')
-rw-r--r--src/cpp/thread_manager/thread_manager.cc19
-rw-r--r--src/cpp/thread_manager/thread_manager.h4
2 files changed, 5 insertions, 18 deletions
diff --git a/src/cpp/thread_manager/thread_manager.cc b/src/cpp/thread_manager/thread_manager.cc
index 73c59eeff0..ebcc4dd378 100644
--- a/src/cpp/thread_manager/thread_manager.cc
+++ b/src/cpp/thread_manager/thread_manager.cc
@@ -109,22 +109,13 @@ void ThreadManager::CleanupCompletedThreads() {
}
void ThreadManager::Initialize() {
- for (int i = 0; i < min_pollers_; i++) {
- MaybeCreatePoller();
+ {
+ std::unique_lock<std::mutex> lock(mu_);
+ num_pollers_ = min_pollers_;
+ num_threads_ = min_pollers_;
}
-}
-
-// Create a new poller if the current number of pollers i.e num_pollers_ (i.e
-// threads currently blocked in PollForWork()) is below the threshold (i.e
-// min_pollers_) and the total number of threads is below the maximum threshold
-void ThreadManager::MaybeCreatePoller() {
- std::unique_lock<std::mutex> lock(mu_);
- if (!shutdown_ && num_pollers_ < min_pollers_) {
- num_pollers_++;
- num_threads_++;
-
- lock.unlock();
+ for (int i = 0; i < min_pollers_; i++) {
// Create a new thread (which ends up calling the MainWorkLoop() function
new WorkerThread(this);
}
diff --git a/src/cpp/thread_manager/thread_manager.h b/src/cpp/thread_manager/thread_manager.h
index c9435011f9..d1050f6ded 100644
--- a/src/cpp/thread_manager/thread_manager.h
+++ b/src/cpp/thread_manager/thread_manager.h
@@ -122,10 +122,6 @@ class ThreadManager {
// The main funtion in ThreadManager
void MainWorkLoop();
- // Create a new poller if the number of current pollers is less than the
- // minimum number of pollers needed (i.e min_pollers).
- void MaybeCreatePoller();
-
void MarkAsCompleted(WorkerThread* thd);
void CleanupCompletedThreads();