From 4818150728ba9edf84231a726048763cf555a81a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 18 Apr 2017 13:09:54 -0700 Subject: Better commentary --- src/cpp/thread_manager/thread_manager.cc | 4 ++++ 1 file changed, 4 insertions(+) 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 -- cgit v1.2.3