diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2017-08-07 11:02:00 -0400 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2017-08-07 11:05:39 -0400 |
commit | 12fd177204d89de3c7d5daabac1000008bc5c630 (patch) | |
tree | af0b2963dd64a8bf1fd9fa6bdb558ca825f02cbc | |
parent | e0f57a38960946dedf9841ddfdd668c5f2a34e5a (diff) | |
download | mongo-12fd177204d89de3c7d5daabac1000008bc5c630.tar.gz |
Revert "SERVER-30254 Make ThreadPool::join finish remaining tasks on a pristine thread instead of inline"
This reverts commit 1cf5b5612d942e948c9a78115fc8980a10bbeca5.
-rw-r--r-- | src/mongo/util/concurrency/thread_pool.cpp | 22 | ||||
-rw-r--r-- | src/mongo/util/concurrency/thread_pool.h | 6 |
2 files changed, 2 insertions, 26 deletions
diff --git a/src/mongo/util/concurrency/thread_pool.cpp b/src/mongo/util/concurrency/thread_pool.cpp index 279d85bc85d..5ea024725e0 100644 --- a/src/mongo/util/concurrency/thread_pool.cpp +++ b/src/mongo/util/concurrency/thread_pool.cpp @@ -157,10 +157,8 @@ void ThreadPool::_join_inlock(stdx::unique_lock<stdx::mutex>* lk) { }); _setState_inlock(joining); ++_numIdleThreads; - if (!_pendingTasks.empty()) { - lk->unlock(); - _drainPendingTasks(); - lk->lock(); + while (!_pendingTasks.empty()) { + _doOneTask(lk); } --_numIdleThreads; ThreadList threadsToJoin; @@ -174,22 +172,6 @@ void ThreadPool::_join_inlock(stdx::unique_lock<stdx::mutex>* lk) { _setState_inlock(shutdownComplete); } -void ThreadPool::_drainPendingTasks() { - // Tasks cannot be run inline because they can create OperationContexts and the join() caller - // may already have one associated with the thread. - stdx::thread cleanThread = stdx::thread([&] { - const std::string threadName = str::stream() << _options.threadNamePrefix - << _nextThreadId++; - setThreadName(threadName); - _options.onCreateThread(threadName); - while (!_pendingTasks.empty()) { - stdx::unique_lock<stdx::mutex> lock(_mutex); - _doOneTask(&lock); - } - }); - cleanThread.join(); -} - Status ThreadPool::schedule(Task task) { stdx::lock_guard<stdx::mutex> lk(_mutex); switch (_state) { diff --git a/src/mongo/util/concurrency/thread_pool.h b/src/mongo/util/concurrency/thread_pool.h index d88787fa484..982e11e250b 100644 --- a/src/mongo/util/concurrency/thread_pool.h +++ b/src/mongo/util/concurrency/thread_pool.h @@ -186,12 +186,6 @@ private: void _join_inlock(stdx::unique_lock<stdx::mutex>* lk); /** - * Runs the remaining tasks on a new thread as part of the join process, blocking until - * complete. Caller must not hold the mutex! - */ - void _drainPendingTasks(); - - /** * Executes one task from _pendingTasks. "lk" must own _mutex, and _pendingTasks must have at * least one entry. */ |