diff options
Diffstat (limited to 'src/mongo/util/concurrency')
-rw-r--r-- | src/mongo/util/concurrency/rwlockimpl.cpp | 2 | ||||
-rw-r--r-- | src/mongo/util/concurrency/thread_pool.cpp | 32 | ||||
-rw-r--r-- | src/mongo/util/concurrency/thread_pool_test_common.cpp | 63 | ||||
-rw-r--r-- | src/mongo/util/concurrency/ticketholder.cpp | 3 |
4 files changed, 49 insertions, 51 deletions
diff --git a/src/mongo/util/concurrency/rwlockimpl.cpp b/src/mongo/util/concurrency/rwlockimpl.cpp index 28eeebd363b..755724cd3a5 100644 --- a/src/mongo/util/concurrency/rwlockimpl.cpp +++ b/src/mongo/util/concurrency/rwlockimpl.cpp @@ -34,9 +34,9 @@ #define NOMINMAX #include <windows.h> #endif +#include <boost/version.hpp> #include <map> #include <set> -#include <boost/version.hpp> #include "mongo/config.h" #include "mongo/stdx/condition_variable.h" diff --git a/src/mongo/util/concurrency/thread_pool.cpp b/src/mongo/util/concurrency/thread_pool.cpp index 4a5e456b972..90464d7b167 100644 --- a/src/mongo/util/concurrency/thread_pool.cpp +++ b/src/mongo/util/concurrency/thread_pool.cpp @@ -137,23 +137,21 @@ void ThreadPool::join() { } void ThreadPool::_join_inlock(stdx::unique_lock<stdx::mutex>* lk) { - _stateChange.wait(*lk, - [this] { - switch (_state) { - case preStart: - return false; - case running: - return false; - case joinRequired: - return true; - case joining: - case shutdownComplete: - severe() << "Attempted to join pool " << _options.poolName - << " more than once"; - fassertFailed(28700); - } - MONGO_UNREACHABLE; - }); + _stateChange.wait(*lk, [this] { + switch (_state) { + case preStart: + return false; + case running: + return false; + case joinRequired: + return true; + case joining: + case shutdownComplete: + severe() << "Attempted to join pool " << _options.poolName << " more than once"; + fassertFailed(28700); + } + MONGO_UNREACHABLE; + }); _setState_inlock(joining); ++_numIdleThreads; while (!_pendingTasks.empty()) { diff --git a/src/mongo/util/concurrency/thread_pool_test_common.cpp b/src/mongo/util/concurrency/thread_pool_test_common.cpp index 1f965e4a2c4..ea63df2df83 100644 --- a/src/mongo/util/concurrency/thread_pool_test_common.cpp +++ b/src/mongo/util/concurrency/thread_pool_test_common.cpp @@ -99,40 +99,39 @@ public: } }; -#define COMMON_THREAD_POOL_TEST(TEST_NAME) \ - class TPT_##TEST_NAME : public CommonThreadPoolTestFixture { \ - public: \ - TPT_##TEST_NAME(ThreadPoolFactory makeThreadPool) \ - : CommonThreadPoolTestFixture(std::move(makeThreadPool)) {} \ - \ - private: \ - void _doTest() override; \ - static const TptRegistrationAgent _agent; \ - }; \ - const TptRegistrationAgent TPT_##TEST_NAME::_agent(#TEST_NAME, \ - [](ThreadPoolFactory makeThreadPool) { \ - return stdx::make_unique<TPT_##TEST_NAME>(std::move(makeThreadPool)); \ - }); \ +#define COMMON_THREAD_POOL_TEST(TEST_NAME) \ + class TPT_##TEST_NAME : public CommonThreadPoolTestFixture { \ + public: \ + TPT_##TEST_NAME(ThreadPoolFactory makeThreadPool) \ + : CommonThreadPoolTestFixture(std::move(makeThreadPool)) {} \ + \ + private: \ + void _doTest() override; \ + static const TptRegistrationAgent _agent; \ + }; \ + const TptRegistrationAgent TPT_##TEST_NAME::_agent( \ + #TEST_NAME, [](ThreadPoolFactory makeThreadPool) { \ + return stdx::make_unique<TPT_##TEST_NAME>(std::move(makeThreadPool)); \ + }); \ void TPT_##TEST_NAME::_doTest() -#define COMMON_THREAD_POOL_DEATH_TEST(TEST_NAME, MATCH_EXPR) \ - class TPT_##TEST_NAME : public CommonThreadPoolTestFixture { \ - public: \ - TPT_##TEST_NAME(ThreadPoolFactory makeThreadPool) \ - : CommonThreadPoolTestFixture(std::move(makeThreadPool)) {} \ - \ - private: \ - void _doTest() override; \ - static const TptDeathRegistrationAgent<TPT_##TEST_NAME> _agent; \ - }; \ - const TptDeathRegistrationAgent<TPT_##TEST_NAME> TPT_##TEST_NAME::_agent( \ - #TEST_NAME, \ - [](ThreadPoolFactory makeThreadPool) { \ - return stdx::make_unique<TPT_##TEST_NAME>(std::move(makeThreadPool)); \ - }); \ - std::string getDeathTestPattern(TPT_##TEST_NAME*) { \ - return MATCH_EXPR; \ - } \ +#define COMMON_THREAD_POOL_DEATH_TEST(TEST_NAME, MATCH_EXPR) \ + class TPT_##TEST_NAME : public CommonThreadPoolTestFixture { \ + public: \ + TPT_##TEST_NAME(ThreadPoolFactory makeThreadPool) \ + : CommonThreadPoolTestFixture(std::move(makeThreadPool)) {} \ + \ + private: \ + void _doTest() override; \ + static const TptDeathRegistrationAgent<TPT_##TEST_NAME> _agent; \ + }; \ + const TptDeathRegistrationAgent<TPT_##TEST_NAME> TPT_##TEST_NAME::_agent( \ + #TEST_NAME, [](ThreadPoolFactory makeThreadPool) { \ + return stdx::make_unique<TPT_##TEST_NAME>(std::move(makeThreadPool)); \ + }); \ + std::string getDeathTestPattern(TPT_##TEST_NAME*) { \ + return MATCH_EXPR; \ + } \ void TPT_##TEST_NAME::_doTest() COMMON_THREAD_POOL_TEST(UnusedPool) { diff --git a/src/mongo/util/concurrency/ticketholder.cpp b/src/mongo/util/concurrency/ticketholder.cpp index 34535fa98b6..3a99d643419 100644 --- a/src/mongo/util/concurrency/ticketholder.cpp +++ b/src/mongo/util/concurrency/ticketholder.cpp @@ -96,7 +96,8 @@ Status TicketHolder::resize(int newSize) { if (newSize > SEM_VALUE_MAX) return Status(ErrorCodes::BadValue, str::stream() << "Maximum value for semaphore is " << SEM_VALUE_MAX - << "; given " << newSize); + << "; given " + << newSize); while (_outof.load() < newSize) { release(); |