diff options
author | Ben Caimano <ben.caimano@mongodb.com> | 2019-09-17 23:22:19 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-09-17 23:22:19 +0000 |
commit | bc11369435ca51e2ff6897433d00f6b909f6a25f (patch) | |
tree | 251653ec8285d798b41846e343e7e414e80ff277 /src/mongo/watchdog | |
parent | 45aea2495306dd61fab46bd398735bb6aaf7b53a (diff) | |
download | mongo-bc11369435ca51e2ff6897433d00f6b909f6a25f.tar.gz |
SERVER-42165 Replace uses of stdx::mutex with mongo::Mutex
Diffstat (limited to 'src/mongo/watchdog')
-rw-r--r-- | src/mongo/watchdog/watchdog.cpp | 16 | ||||
-rw-r--r-- | src/mongo/watchdog/watchdog.h | 8 | ||||
-rw-r--r-- | src/mongo/watchdog/watchdog_test.cpp | 22 |
3 files changed, 23 insertions, 23 deletions
diff --git a/src/mongo/watchdog/watchdog.cpp b/src/mongo/watchdog/watchdog.cpp index bc12a7fb1eb..360b98a0be9 100644 --- a/src/mongo/watchdog/watchdog.cpp +++ b/src/mongo/watchdog/watchdog.cpp @@ -61,7 +61,7 @@ WatchdogPeriodicThread::WatchdogPeriodicThread(Milliseconds period, StringData t void WatchdogPeriodicThread::start() { { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); invariant(_state == State::kNotStarted); _state = State::kStarted; @@ -76,7 +76,7 @@ void WatchdogPeriodicThread::shutdown() { stdx::thread thread; { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); bool started = (_state == State::kStarted); @@ -101,7 +101,7 @@ void WatchdogPeriodicThread::shutdown() { } void WatchdogPeriodicThread::setPeriod(Milliseconds period) { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); bool wasEnabled = _enabled; @@ -130,7 +130,7 @@ void WatchdogPeriodicThread::doLoop() { auto preciseClockSource = client->getServiceContext()->getPreciseClockSource(); { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); // Ensure state is starting from a clean slate. resetState(); @@ -144,7 +144,7 @@ void WatchdogPeriodicThread::doLoop() { Date_t startTime = preciseClockSource->now(); { - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); MONGO_IDLE_THREAD_BLOCK; @@ -257,7 +257,7 @@ void WatchdogMonitor::start() { _watchdogMonitorThread.start(); { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); invariant(_state == State::kNotStarted); _state = State::kStarted; @@ -266,7 +266,7 @@ void WatchdogMonitor::start() { void WatchdogMonitor::setPeriod(Milliseconds duration) { { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); if (duration > Milliseconds(0)) { dassert(duration >= Milliseconds(1)); @@ -290,7 +290,7 @@ void WatchdogMonitor::setPeriod(Milliseconds duration) { void WatchdogMonitor::shutdown() { { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); bool started = (_state == State::kStarted); diff --git a/src/mongo/watchdog/watchdog.h b/src/mongo/watchdog/watchdog.h index bd29038a12a..289d2dadac9 100644 --- a/src/mongo/watchdog/watchdog.h +++ b/src/mongo/watchdog/watchdog.h @@ -35,8 +35,8 @@ #include <vector> #include "mongo/platform/atomic_word.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/stdx/thread.h" #include "mongo/util/duration.h" @@ -204,7 +204,7 @@ private: stdx::thread _thread; // Lock to protect _state and control _thread - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("WatchdogPeriodicThread::_mutex"); stdx::condition_variable _condvar; }; @@ -367,7 +367,7 @@ private: }; // Lock to protect _state and control _thread - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("WatchdogMonitor::_mutex"); // State of watchdog State _state{State::kNotStarted}; diff --git a/src/mongo/watchdog/watchdog_test.cpp b/src/mongo/watchdog/watchdog_test.cpp index ed62f7b9060..bc8bac2cc7b 100644 --- a/src/mongo/watchdog/watchdog_test.cpp +++ b/src/mongo/watchdog/watchdog_test.cpp @@ -54,7 +54,7 @@ public: void run(OperationContext* opCtx) final { { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); ++_counter; } @@ -70,7 +70,7 @@ public: void waitForCount() { invariant(_wait != 0); - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); while (_counter < _wait) { _condvar.wait(lock); } @@ -80,7 +80,7 @@ public: std::uint32_t getCounter() { { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); return _counter; } } @@ -88,7 +88,7 @@ public: private: std::uint32_t _counter{0}; - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("TestPeriodicThread::_mutex"); stdx::condition_variable _condvar; std::uint32_t _wait{0}; }; @@ -198,7 +198,7 @@ class TestCounterCheck : public WatchdogCheck { public: void run(OperationContext* opCtx) final { { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); ++_counter; } @@ -218,7 +218,7 @@ public: void waitForCount() { invariant(_wait != 0); - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); while (_counter < _wait) { _condvar.wait(lock); } @@ -226,7 +226,7 @@ public: std::uint32_t getCounter() { { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); return _counter; } } @@ -234,7 +234,7 @@ public: private: std::uint32_t _counter{0}; - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("TestCounterCheck::_mutex"); stdx::condition_variable _condvar; std::uint32_t _wait{0}; }; @@ -274,14 +274,14 @@ TEST_F(WatchdogCheckThreadTest, Basic) { class ManualResetEvent { public: void set() { - stdx::lock_guard<stdx::mutex> lock(_mutex); + stdx::lock_guard<Latch> lock(_mutex); _set = true; _condvar.notify_one(); } void wait() { - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); _condvar.wait(lock, [this]() { return _set; }); } @@ -289,7 +289,7 @@ public: private: bool _set{false}; - stdx::mutex _mutex; + Mutex _mutex = MONGO_MAKE_LATCH("ManualResetEvent::_mutex"); stdx::condition_variable _condvar; }; |