From bc11369435ca51e2ff6897433d00f6b909f6a25f Mon Sep 17 00:00:00 2001 From: Ben Caimano Date: Tue, 17 Sep 2019 23:22:19 +0000 Subject: SERVER-42165 Replace uses of stdx::mutex with mongo::Mutex --- src/mongo/db/free_mon/free_mon_controller.cpp | 18 +++++++++--------- src/mongo/db/free_mon/free_mon_controller.h | 2 +- src/mongo/db/free_mon/free_mon_controller_test.cpp | 22 +++++++++++----------- src/mongo/db/free_mon/free_mon_message.h | 10 +++++----- src/mongo/db/free_mon/free_mon_processor.h | 8 ++++---- src/mongo/db/free_mon/free_mon_queue.cpp | 8 ++++---- src/mongo/db/free_mon/free_mon_queue.h | 2 +- 7 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/mongo/db/free_mon') diff --git a/src/mongo/db/free_mon/free_mon_controller.cpp b/src/mongo/db/free_mon/free_mon_controller.cpp index 057ae5ecd7a..a9de7ca4c49 100644 --- a/src/mongo/db/free_mon/free_mon_controller.cpp +++ b/src/mongo/db/free_mon/free_mon_controller.cpp @@ -61,7 +61,7 @@ FreeMonNetworkInterface::~FreeMonNetworkInterface() = default; void FreeMonController::addRegistrationCollector( std::unique_ptr collector) { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); invariant(_state == State::kNotStarted); _registrationCollectors.add(std::move(collector)); @@ -70,7 +70,7 @@ void FreeMonController::addRegistrationCollector( void FreeMonController::addMetricsCollector(std::unique_ptr collector) { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); invariant(_state == State::kNotStarted); _metricCollectors.add(std::move(collector)); @@ -128,7 +128,7 @@ void FreeMonController::notifyOnRollback() { void FreeMonController::_enqueue(std::shared_ptr msg) { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); invariant(_state == State::kStarted); } @@ -139,7 +139,7 @@ void FreeMonController::start(RegistrationType registrationType, std::vector& tags, Seconds gatherMetricsInterval) { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); invariant(_state == State::kNotStarted); } @@ -154,7 +154,7 @@ void FreeMonController::start(RegistrationType registrationType, _thread = stdx::thread([this] { _processor->run(); }); { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); invariant(_state == State::kNotStarted); _state = State::kStarted; @@ -170,7 +170,7 @@ void FreeMonController::stop() { log() << "Shutting down free monitoring"; { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); bool started = (_state == State::kStarted); @@ -194,7 +194,7 @@ void FreeMonController::stop() { void FreeMonController::turnCrankForTest(size_t countMessagesToIgnore) { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); invariant(_state == State::kStarted); } @@ -205,7 +205,7 @@ void FreeMonController::turnCrankForTest(size_t countMessagesToIgnore) { void FreeMonController::getStatus(OperationContext* opCtx, BSONObjBuilder* status) { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); if (_state != State::kStarted) { status->append("state", "disabled"); @@ -218,7 +218,7 @@ void FreeMonController::getStatus(OperationContext* opCtx, BSONObjBuilder* statu void FreeMonController::getServerStatus(OperationContext* opCtx, BSONObjBuilder* status) { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); if (_state != State::kStarted) { status->append("state", "disabled"); diff --git a/src/mongo/db/free_mon/free_mon_controller.h b/src/mongo/db/free_mon/free_mon_controller.h index 9307ab7570c..5c74a8a4b5f 100644 --- a/src/mongo/db/free_mon/free_mon_controller.h +++ b/src/mongo/db/free_mon/free_mon_controller.h @@ -191,7 +191,7 @@ private: State _state{State::kNotStarted}; // Mutext to protect internal state - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("FreeMonController::_mutex"); // Set of registration collectors FreeMonCollectorCollection _registrationCollectors; diff --git a/src/mongo/db/free_mon/free_mon_controller_test.cpp b/src/mongo/db/free_mon/free_mon_controller_test.cpp index 090eed90cc9..4db1bfa3c44 100644 --- a/src/mongo/db/free_mon/free_mon_controller_test.cpp +++ b/src/mongo/db/free_mon/free_mon_controller_test.cpp @@ -86,7 +86,7 @@ public: builder.append("mock", "some data"); { - stdx::lock_guard lck(_mutex); + stdx::lock_guard lck(_mutex); ++_counter; @@ -105,12 +105,12 @@ public: } std::uint32_t count() { - stdx::lock_guard lck(_mutex); + stdx::lock_guard lck(_mutex); return _counter; } void wait() { - stdx::unique_lock lck(_mutex); + stdx::unique_lock lck(_mutex); while (_counter < _wait) { _condvar.wait(lck); } @@ -130,7 +130,7 @@ private: std::uint32_t _counter{0}; - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("FreeMonMetricsCollectorMock::_mutex"); stdx::condition_variable _condvar; std::uint32_t _wait{0}; }; @@ -158,7 +158,7 @@ public: * Set the count of events to wait for. */ void reset(uint32_t count) { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); ASSERT_EQ(_count, 0UL); ASSERT_GT(count, 0UL); @@ -170,7 +170,7 @@ public: * Set the payload and signal waiter. */ void set(T payload) { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); if (_count > 0) { --_count; @@ -187,7 +187,7 @@ public: * Returns boost::none on timeout. */ boost::optional wait_for(Milliseconds duration) { - stdx::unique_lock lock(_mutex); + stdx::unique_lock lock(_mutex); if (!_condvar.wait_for( lock, duration.toSystemDuration(), [this]() { return _count == 0; })) { @@ -202,7 +202,7 @@ private: stdx::condition_variable _condvar; // Lock for condition variable and to protect state - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("CountdownLatchResult::_mutex"); // Count to wait fore uint32_t _count; @@ -309,7 +309,7 @@ public: auto cdr = req.getMetrics(); { - stdx::lock_guard lock(_metricsLock); + stdx::lock_guard lock(_metricsLock); auto metrics = decompressMetrics(cdr); _lastMetrics = metrics; _countdownMetrics.set(metrics); @@ -354,7 +354,7 @@ public: } BSONArray getLastMetrics() { - stdx::lock_guard lock(_metricsLock); + stdx::lock_guard lock(_metricsLock); return _lastMetrics; } @@ -365,7 +365,7 @@ private: executor::ThreadPoolTaskExecutor* _threadPool; - stdx::mutex _metricsLock; + Mutex _metricsLock = MONGO_MAKE_LATCH("FreeMonNetworkInterfaceMock::_metricsLock"); BSONArray _lastMetrics; Options _options; diff --git a/src/mongo/db/free_mon/free_mon_message.h b/src/mongo/db/free_mon/free_mon_message.h index 71a34dd84b4..11fab7c8501 100644 --- a/src/mongo/db/free_mon/free_mon_message.h +++ b/src/mongo/db/free_mon/free_mon_message.h @@ -33,8 +33,8 @@ #include #include "mongo/db/free_mon/free_mon_protocol_gen.h" -#include "mongo/stdx/condition_variable.h" -#include "mongo/stdx/mutex.h" +#include "mongo/platform/condition_variable.h" +#include "mongo/platform/mutex.h" #include "mongo/util/duration.h" #include "mongo/util/time_support.h" @@ -292,7 +292,7 @@ public: * Set Status and signal waiter. */ void set(Status status) { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); invariant(!_set); if (!_set) { @@ -308,7 +308,7 @@ public: * Returns boost::none on timeout. */ boost::optional wait_for(Milliseconds duration) { - stdx::unique_lock lock(_mutex); + stdx::unique_lock lock(_mutex); if (!_condvar.wait_for(lock, duration.toSystemDuration(), [this]() { return _set; })) { return {}; @@ -322,7 +322,7 @@ private: stdx::condition_variable _condvar; // Lock for condition variable and to protect state - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("WaitableResult::_mutex"); // Indicates whether _status has been set bool _set{false}; diff --git a/src/mongo/db/free_mon/free_mon_processor.h b/src/mongo/db/free_mon/free_mon_processor.h index 11584595147..ab519bfb84d 100644 --- a/src/mongo/db/free_mon/free_mon_processor.h +++ b/src/mongo/db/free_mon/free_mon_processor.h @@ -235,7 +235,7 @@ public: * Reset countdown latch wait for N events. */ void reset(uint32_t count) { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); dassert(_count == 0); dassert(count > 0); _count = count; @@ -245,7 +245,7 @@ public: * Count down an event. */ void countDown() { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); if (_count > 0) { --_count; @@ -259,13 +259,13 @@ public: * Wait until the N events specified in reset have occured. */ void wait() { - stdx::unique_lock lock(_mutex); + stdx::unique_lock lock(_mutex); _condvar.wait(lock, [&] { return _count == 0; }); } private: // mutex to break count and cond var - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("FreeMonCountdownLatch::_mutex"); // cond var to signal and wait on stdx::condition_variable _condvar; diff --git a/src/mongo/db/free_mon/free_mon_queue.cpp b/src/mongo/db/free_mon/free_mon_queue.cpp index d2cc1115ef5..56b01eade93 100644 --- a/src/mongo/db/free_mon/free_mon_queue.cpp +++ b/src/mongo/db/free_mon/free_mon_queue.cpp @@ -74,7 +74,7 @@ FreeMonMessage::~FreeMonMessage() {} void FreeMonMessageQueue::enqueue(std::shared_ptr msg) { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); // If we were stopped, drop messages if (_stop) { @@ -98,7 +98,7 @@ void FreeMonMessageQueue::enqueue(std::shared_ptr msg) { boost::optional> FreeMonMessageQueue::dequeue( ClockSource* clockSource) { { - stdx::unique_lock lock(_mutex); + stdx::unique_lock lock(_mutex); if (_stop) { return {}; } @@ -188,7 +188,7 @@ boost::optional> FreeMonMessageQueue::dequeue( void FreeMonMessageQueue::stop() { { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); // We can be stopped twice in some situations: // 1. Stop on unexpected error @@ -204,7 +204,7 @@ void FreeMonMessageQueue::turnCrankForTest(size_t countMessagesToIgnore) { invariant(_useCrank); { - stdx::lock_guard lock(_mutex); + stdx::lock_guard lock(_mutex); _waitable = std::make_unique(); diff --git a/src/mongo/db/free_mon/free_mon_queue.h b/src/mongo/db/free_mon/free_mon_queue.h index 18be1b7a330..6e7bb85dcbf 100644 --- a/src/mongo/db/free_mon/free_mon_queue.h +++ b/src/mongo/db/free_mon/free_mon_queue.h @@ -133,7 +133,7 @@ private: stdx::condition_variable _condvar; // Lock for condition variable and to protect state - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("FreeMonMessageQueue::_mutex"); // Indicates whether queue has been stopped. bool _stop{false}; -- cgit v1.2.1