diff options
author | Craig Tiller <ctiller@google.com> | 2017-04-18 13:09:54 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-04-18 13:09:54 -0700 |
commit | 4818150728ba9edf84231a726048763cf555a81a (patch) | |
tree | cac09b9ca473191cbb6c41f64ce91cccaaa3b3fa | |
parent | a3e87894f2cc921d2c5bbdab250fa23a1ba8b52d (diff) |
Better commentary
-rw-r--r-- | src/cpp/thread_manager/thread_manager.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cpp/thread_manager/thread_manager.cc b/src/cpp/thread_manager/thread_manager.cc index 39b9691b5f..73c59eeff0 100644 --- a/src/cpp/thread_manager/thread_manager.cc +++ b/src/cpp/thread_manager/thread_manager.cc @@ -156,12 +156,16 @@ void ThreadManager::MainWorkLoop() { if (!shutdown_ && num_pollers_ < min_pollers_) { num_pollers_++; num_threads_++; + // Drop lock before spawning thread to avoid contention lock.unlock(); new WorkerThread(this); } else { + // Drop lock for consistency with above branch lock.unlock(); } + // Lock is always released at this point - do the application work DoWork(tag, ok); + // Take the lock again to check post conditions lock.lock(); // If we're shutdown, we should finish at this point. // If not, there's a chance that we'll exceed the max poller count: that |