summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@mongodb.com>2019-09-17 23:22:19 +0000
committerevergreen <evergreen@mongodb.com>2019-09-17 23:22:19 +0000
commitbc11369435ca51e2ff6897433d00f6b909f6a25f (patch)
tree251653ec8285d798b41846e343e7e414e80ff277 /src/mongo/db/concurrency
parent45aea2495306dd61fab46bd398735bb6aaf7b53a (diff)
downloadmongo-bc11369435ca51e2ff6897433d00f6b909f6a25f.tar.gz
SERVER-42165 Replace uses of stdx::mutex with mongo::Mutex
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r--src/mongo/db/concurrency/d_concurrency.cpp8
-rw-r--r--src/mongo/db/concurrency/d_concurrency_bm.cpp6
-rw-r--r--src/mongo/db/concurrency/deferred_writer.cpp4
-rw-r--r--src/mongo/db/concurrency/deferred_writer.h4
-rw-r--r--src/mongo/db/concurrency/flow_control_ticketholder.cpp6
-rw-r--r--src/mongo/db/concurrency/flow_control_ticketholder.h6
-rw-r--r--src/mongo/db/concurrency/lock_manager.h4
-rw-r--r--src/mongo/db/concurrency/lock_state.cpp6
-rw-r--r--src/mongo/db/concurrency/lock_state.h2
9 files changed, 23 insertions, 23 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp
index 5daed970104..28d5017f6ae 100644
--- a/src/mongo/db/concurrency/d_concurrency.cpp
+++ b/src/mongo/db/concurrency/d_concurrency.cpp
@@ -41,7 +41,7 @@
#include "mongo/db/concurrency/flow_control_ticketholder.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/service_context.h"
-#include "mongo/stdx/mutex.h"
+#include "mongo/platform/mutex.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
#include "mongo/util/stacktrace.h"
@@ -77,7 +77,7 @@ public:
}
static std::string nameForId(ResourceId resourceId) {
- stdx::lock_guard<stdx::mutex> lk(resourceIdFactory->labelsMutex);
+ stdx::lock_guard<Latch> lk(resourceIdFactory->labelsMutex);
return resourceIdFactory->labels.at(resourceId.getHashId());
}
@@ -93,7 +93,7 @@ public:
private:
ResourceId _newResourceIdForMutex(std::string resourceLabel) {
- stdx::lock_guard<stdx::mutex> lk(labelsMutex);
+ stdx::lock_guard<Latch> lk(labelsMutex);
invariant(nextId == labels.size());
labels.push_back(std::move(resourceLabel));
@@ -104,7 +104,7 @@ private:
std::uint64_t nextId = 0;
std::vector<std::string> labels;
- stdx::mutex labelsMutex;
+ Mutex labelsMutex = MONGO_MAKE_LATCH("ResourceIdFactory::labelsMutex");
};
ResourceIdFactory* ResourceIdFactory::resourceIdFactory;
diff --git a/src/mongo/db/concurrency/d_concurrency_bm.cpp b/src/mongo/db/concurrency/d_concurrency_bm.cpp
index 95c6771badf..a13df7a3ea4 100644
--- a/src/mongo/db/concurrency/d_concurrency_bm.cpp
+++ b/src/mongo/db/concurrency/d_concurrency_bm.cpp
@@ -34,7 +34,7 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/lock_manager_test_help.h"
#include "mongo/db/storage/recovery_unit_noop.h"
-#include "mongo/stdx/mutex.h"
+#include "mongo/platform/mutex.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -67,10 +67,10 @@ protected:
};
BENCHMARK_DEFINE_F(DConcurrencyTest, BM_StdMutex)(benchmark::State& state) {
- static stdx::mutex mtx;
+ static auto mtx = MONGO_MAKE_LATCH();
for (auto keepRunning : state) {
- stdx::unique_lock<stdx::mutex> lk(mtx);
+ stdx::unique_lock<Latch> lk(mtx);
}
}
diff --git a/src/mongo/db/concurrency/deferred_writer.cpp b/src/mongo/db/concurrency/deferred_writer.cpp
index 6f7c7df6ea5..4bedbe1995c 100644
--- a/src/mongo/db/concurrency/deferred_writer.cpp
+++ b/src/mongo/db/concurrency/deferred_writer.cpp
@@ -118,7 +118,7 @@ void DeferredWriter::_worker(InsertStatement stmt) {
return Status::OK();
});
- stdx::lock_guard<stdx::mutex> lock(_mutex);
+ stdx::lock_guard<Latch> lock(_mutex);
_numBytes -= stmt.doc.objsize();
@@ -166,7 +166,7 @@ bool DeferredWriter::insertDocument(BSONObj obj) {
// We can't insert documents if we haven't been started up.
invariant(_pool);
- stdx::lock_guard<stdx::mutex> lock(_mutex);
+ stdx::lock_guard<Latch> lock(_mutex);
// Check if we're allowed to insert this object.
if (_numBytes + obj.objsize() >= _maxNumBytes) {
diff --git a/src/mongo/db/concurrency/deferred_writer.h b/src/mongo/db/concurrency/deferred_writer.h
index d573f497851..0ac8238fa8d 100644
--- a/src/mongo/db/concurrency/deferred_writer.h
+++ b/src/mongo/db/concurrency/deferred_writer.h
@@ -32,7 +32,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
-#include "mongo/stdx/mutex.h"
+#include "mongo/platform/mutex.h"
namespace mongo {
@@ -158,7 +158,7 @@ private:
/**
* Guards all non-const, non-thread-safe members.
*/
- stdx::mutex _mutex;
+ Mutex _mutex = MONGO_MAKE_LATCH("DeferredWriter::_mutex");
/**
* The number of bytes currently in the in-memory buffer.
diff --git a/src/mongo/db/concurrency/flow_control_ticketholder.cpp b/src/mongo/db/concurrency/flow_control_ticketholder.cpp
index 8055a7597bd..6bb95797502 100644
--- a/src/mongo/db/concurrency/flow_control_ticketholder.cpp
+++ b/src/mongo/db/concurrency/flow_control_ticketholder.cpp
@@ -80,7 +80,7 @@ void FlowControlTicketholder::set(ServiceContext* service,
void FlowControlTicketholder::refreshTo(int numTickets) {
invariant(numTickets >= 0);
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
LOG(4) << "Refreshing tickets. Before: " << _tickets << " Now: " << numTickets;
_tickets = numTickets;
_cv.notify_all();
@@ -88,7 +88,7 @@ void FlowControlTicketholder::refreshTo(int numTickets) {
void FlowControlTicketholder::getTicket(OperationContext* opCtx,
FlowControlTicketholder::CurOp* stats) {
- stdx::unique_lock<stdx::mutex> lk(_mutex);
+ stdx::unique_lock<Latch> lk(_mutex);
if (_inShutdown) {
return;
}
@@ -135,7 +135,7 @@ void FlowControlTicketholder::getTicket(OperationContext* opCtx,
// Should only be called once, during shutdown.
void FlowControlTicketholder::setInShutdown() {
LOG(0) << "Stopping further Flow Control ticket acquisitions.";
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
_inShutdown = true;
_cv.notify_all();
}
diff --git a/src/mongo/db/concurrency/flow_control_ticketholder.h b/src/mongo/db/concurrency/flow_control_ticketholder.h
index 599779ddd15..39413477937 100644
--- a/src/mongo/db/concurrency/flow_control_ticketholder.h
+++ b/src/mongo/db/concurrency/flow_control_ticketholder.h
@@ -31,8 +31,8 @@
#include "mongo/bson/bsonobjbuilder.h"
#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"
namespace mongo {
@@ -93,7 +93,7 @@ private:
// Use an int64_t as this is serialized to bson which does not support unsigned 64-bit numbers.
AtomicWord<std::int64_t> _totalTimeAcquiringMicros;
- stdx::mutex _mutex;
+ Mutex _mutex = MONGO_MAKE_LATCH("FlowControlTicketHolder::_mutex");
stdx::condition_variable _cv;
int _tickets;
diff --git a/src/mongo/db/concurrency/lock_manager.h b/src/mongo/db/concurrency/lock_manager.h
index 50b2116d953..e8cbfd39054 100644
--- a/src/mongo/db/concurrency/lock_manager.h
+++ b/src/mongo/db/concurrency/lock_manager.h
@@ -40,8 +40,8 @@
#include "mongo/db/concurrency/lock_request_list.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/platform/compiler.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/unordered_map.h"
#include "mongo/util/concurrency/mutex.h"
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp
index fd840437c89..5f5171e6129 100644
--- a/src/mongo/db/concurrency/lock_state.cpp
+++ b/src/mongo/db/concurrency/lock_state.cpp
@@ -220,7 +220,7 @@ void CondVarLockGrantNotification::clear() {
}
LockResult CondVarLockGrantNotification::wait(Milliseconds timeout) {
- stdx::unique_lock<stdx::mutex> lock(_mutex);
+ stdx::unique_lock<Latch> lock(_mutex);
return _cond.wait_for(
lock, timeout.toSystemDuration(), [this] { return _result != LOCK_INVALID; })
? _result
@@ -229,7 +229,7 @@ LockResult CondVarLockGrantNotification::wait(Milliseconds timeout) {
LockResult CondVarLockGrantNotification::wait(OperationContext* opCtx, Milliseconds timeout) {
invariant(opCtx);
- stdx::unique_lock<stdx::mutex> lock(_mutex);
+ stdx::unique_lock<Latch> lock(_mutex);
if (opCtx->waitForConditionOrInterruptFor(
_cond, lock, timeout, [this] { return _result != LOCK_INVALID; })) {
// Because waitForConditionOrInterruptFor evaluates the predicate before checking for
@@ -243,7 +243,7 @@ LockResult CondVarLockGrantNotification::wait(OperationContext* opCtx, Milliseco
}
void CondVarLockGrantNotification::notify(ResourceId resId, LockResult result) {
- stdx::unique_lock<stdx::mutex> lock(_mutex);
+ stdx::unique_lock<Latch> lock(_mutex);
invariant(_result == LOCK_INVALID);
_result = result;
diff --git a/src/mongo/db/concurrency/lock_state.h b/src/mongo/db/concurrency/lock_state.h
index 9371ba0ae13..9994e25f7be 100644
--- a/src/mongo/db/concurrency/lock_state.h
+++ b/src/mongo/db/concurrency/lock_state.h
@@ -75,7 +75,7 @@ private:
virtual void notify(ResourceId resId, LockResult result);
// These two go together to implement the conditional variable pattern.
- stdx::mutex _mutex;
+ Mutex _mutex = MONGO_MAKE_LATCH("CondVarLockGrantNotification::_mutex");
stdx::condition_variable _cond;
// Result from the last call to notify