diff options
Diffstat (limited to 'src/mongo/scripting/deadline_monitor.h')
-rw-r--r-- | src/mongo/scripting/deadline_monitor.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/mongo/scripting/deadline_monitor.h b/src/mongo/scripting/deadline_monitor.h index 03abfcbdac6..39862ebf58c 100644 --- a/src/mongo/scripting/deadline_monitor.h +++ b/src/mongo/scripting/deadline_monitor.h @@ -31,8 +31,8 @@ #include <cstdint> #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/stdx/unordered_map.h" #include "mongo/util/concurrency/idle_thread_block.h" @@ -84,7 +84,7 @@ public: ~DeadlineMonitor() { { // ensure the monitor thread has been stopped before destruction - stdx::lock_guard<stdx::mutex> lk(_deadlineMutex); + stdx::lock_guard<Latch> lk(_deadlineMutex); _inShutdown = true; _newDeadlineAvailable.notify_one(); } @@ -105,7 +105,7 @@ public: } else { deadline = Date_t::max(); } - stdx::lock_guard<stdx::mutex> lk(_deadlineMutex); + stdx::lock_guard<Latch> lk(_deadlineMutex); if (_tasks.find(task) == _tasks.end()) { _tasks.emplace(task, deadline); @@ -123,7 +123,7 @@ public: * @return true if the task was found and erased */ bool stopDeadline(_Task* const task) { - stdx::lock_guard<stdx::mutex> lk(_deadlineMutex); + stdx::lock_guard<Latch> lk(_deadlineMutex); return _tasks.erase(task); } @@ -135,7 +135,7 @@ private: */ void deadlineMonitorThread() { setThreadName("DeadlineMonitor"); - stdx::unique_lock<stdx::mutex> lk(_deadlineMutex); + stdx::unique_lock<Latch> lk(_deadlineMutex); Date_t lastInterruptCycle = Date_t::now(); while (!_inShutdown) { // get the next interval to wait @@ -187,8 +187,9 @@ private: } using TaskDeadlineMap = stdx::unordered_map<_Task*, Date_t>; - TaskDeadlineMap _tasks; // map of running tasks with deadlines - stdx::mutex _deadlineMutex; // protects all non-const members, except _monitorThread + TaskDeadlineMap _tasks; // map of running tasks with deadlines + // protects all non-const members, except _monitorThread + Mutex _deadlineMutex = MONGO_MAKE_LATCH("DeadlineMonitor::_deadlineMutex"); stdx::condition_variable _newDeadlineAvailable; // Signaled for timeout, start and stop stdx::thread _monitorThread; // the deadline monitor thread Date_t _nearestDeadlineWallclock = Date_t::max(); // absolute time of the nearest deadline |