summaryrefslogtreecommitdiff
path: root/src/mongo/shell
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@mongodb.com>2019-11-01 17:24:53 +0000
committerevergreen <evergreen@mongodb.com>2019-11-01 17:24:53 +0000
commitbf5bef47a8e6937b4e0d2c9df3fde3470bdc72c9 (patch)
tree8f71a9f272082dd9ee0e471ef5fcb9f19519600d /src/mongo/shell
parentf210bc645453c05979067c556bf6f2bd43e64134 (diff)
downloadmongo-bf5bef47a8e6937b4e0d2c9df3fde3470bdc72c9.tar.gz
SERVER-42165 Replace uses of stdx::mutex with mongo::Mutex
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/bench.cpp16
-rw-r--r--src/mongo/shell/bench.h6
-rw-r--r--src/mongo/shell/dbshell.cpp2
-rw-r--r--src/mongo/shell/shell_utils.cpp8
-rw-r--r--src/mongo/shell/shell_utils.h6
-rw-r--r--src/mongo/shell/shell_utils_launcher.cpp10
-rw-r--r--src/mongo/shell/shell_utils_launcher.h2
7 files changed, 25 insertions, 25 deletions
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp
index e682a08f2bd..06493a8c364 100644
--- a/src/mongo/shell/bench.cpp
+++ b/src/mongo/shell/bench.cpp
@@ -764,7 +764,7 @@ BenchRunState::~BenchRunState() {
}
void BenchRunState::waitForState(State awaitedState) {
- stdx::unique_lock<stdx::mutex> lk(_mutex);
+ stdx::unique_lock<Latch> lk(_mutex);
switch (awaitedState) {
case BRS_RUNNING:
@@ -792,7 +792,7 @@ void BenchRunState::tellWorkersToCollectStats() {
}
void BenchRunState::assertFinished() const {
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
verify(0 == _numUnstartedWorkers + _numActiveWorkers);
}
@@ -805,7 +805,7 @@ bool BenchRunState::shouldWorkerCollectStats() const {
}
void BenchRunState::onWorkerStarted() {
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
verify(_numUnstartedWorkers > 0);
--_numUnstartedWorkers;
++_numActiveWorkers;
@@ -815,7 +815,7 @@ void BenchRunState::onWorkerStarted() {
}
void BenchRunState::onWorkerFinished() {
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
verify(_numActiveWorkers > 0);
--_numActiveWorkers;
if (_numActiveWorkers + _numUnstartedWorkers == 0) {
@@ -1376,7 +1376,7 @@ void BenchRunWorker::run() {
BenchRunner::BenchRunner(BenchRunConfig* config) : _brState(config->parallel), _config(config) {
_oid.init();
- stdx::lock_guard<stdx::mutex> lk(_staticMutex);
+ stdx::lock_guard<Latch> lk(_staticMutex);
_activeRuns[_oid] = this;
}
@@ -1438,7 +1438,7 @@ void BenchRunner::stop() {
}
{
- stdx::lock_guard<stdx::mutex> lk(_staticMutex);
+ stdx::lock_guard<Latch> lk(_staticMutex);
_activeRuns.erase(_oid);
}
}
@@ -1449,7 +1449,7 @@ BenchRunner* BenchRunner::createWithConfig(const BSONObj& configArgs) {
}
BenchRunner* BenchRunner::get(OID oid) {
- stdx::lock_guard<stdx::mutex> lk(_staticMutex);
+ stdx::lock_guard<Latch> lk(_staticMutex);
return _activeRuns[oid];
}
@@ -1523,7 +1523,7 @@ BSONObj BenchRunner::finish(BenchRunner* runner) {
return zoo;
}
-stdx::mutex BenchRunner::_staticMutex;
+Mutex BenchRunner::_staticMutex = MONGO_MAKE_LATCH("BenchRunner");
std::map<OID, BenchRunner*> BenchRunner::_activeRuns;
/**
diff --git a/src/mongo/shell/bench.h b/src/mongo/shell/bench.h
index f73d2149abe..170023917ac 100644
--- a/src/mongo/shell/bench.h
+++ b/src/mongo/shell/bench.h
@@ -38,8 +38,8 @@
#include "mongo/db/logical_session_id.h"
#include "mongo/db/ops/write_ops_parsers.h"
#include "mongo/platform/atomic_word.h"
+#include "mongo/platform/mutex.h"
#include "mongo/stdx/condition_variable.h"
-#include "mongo/stdx/mutex.h"
#include "mongo/stdx/thread.h"
#include "mongo/util/timer.h"
@@ -449,7 +449,7 @@ public:
void onWorkerFinished();
private:
- mutable stdx::mutex _mutex;
+ mutable Mutex _mutex = MONGO_MAKE_LATCH("BenchRunState::_mutex");
stdx::condition_variable _stateChangeCondition;
@@ -599,7 +599,7 @@ public:
private:
// TODO: Same as for createWithConfig.
- static stdx::mutex _staticMutex;
+ static Mutex _staticMutex;
static std::map<OID, BenchRunner*> _activeRuns;
OID _oid;
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index ce086bb03ee..8e743861d3c 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -158,7 +158,7 @@ private:
// This needs to use a mutex rather than an atomic bool because we need to ensure that no more
// logging will happen once we return from disable().
- static inline stdx::mutex mx;
+ static inline Mutex mx = MONGO_MAKE_LATCH("ShellConsoleAppender::mx");
static inline bool loggingEnabled = true;
};
diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp
index 28b2747b071..df0e8aba43c 100644
--- a/src/mongo/shell/shell_utils.cpp
+++ b/src/mongo/shell/shell_utils.cpp
@@ -50,13 +50,13 @@
#include "mongo/client/dbclient_base.h"
#include "mongo/client/replica_set_monitor.h"
#include "mongo/db/hasher.h"
+#include "mongo/platform/mutex.h"
#include "mongo/platform/random.h"
#include "mongo/scripting/engine.h"
#include "mongo/shell/bench.h"
#include "mongo/shell/shell_options.h"
#include "mongo/shell/shell_utils_extended.h"
#include "mongo/shell/shell_utils_launcher.h"
-#include "mongo/stdx/mutex.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
#include "mongo/util/processinfo.h"
@@ -443,14 +443,14 @@ void ConnectionRegistry::registerConnection(DBClientBase& client) {
BSONObj info;
if (client.runCommand("admin", BSON("whatsmyuri" << 1), info)) {
std::string connstr = client.getServerAddress();
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
_connectionUris[connstr].insert(info["you"].str());
}
}
void ConnectionRegistry::killOperationsOnAllConnections(bool withPrompt) const {
Prompter prompter("do you want to kill the current op(s) on the server?");
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
for (auto& connection : _connectionUris) {
auto status = ConnectionString::parse(connection.first);
if (!status.isOK()) {
@@ -545,6 +545,6 @@ bool fileExists(const std::string& file) {
}
-stdx::mutex& mongoProgramOutputMutex(*(new stdx::mutex()));
+Mutex& mongoProgramOutputMutex(*(new Mutex()));
} // namespace shell_utils
} // namespace mongo
diff --git a/src/mongo/shell/shell_utils.h b/src/mongo/shell/shell_utils.h
index 0f9c7a7615b..5fb2b844eb6 100644
--- a/src/mongo/shell/shell_utils.h
+++ b/src/mongo/shell/shell_utils.h
@@ -35,7 +35,7 @@
#include <string>
#include "mongo/db/jsobj.h"
-#include "mongo/stdx/mutex.h"
+#include "mongo/platform/mutex.h"
#include "mongo/util/concurrency/mutex.h"
namespace mongo {
@@ -82,14 +82,14 @@ public:
private:
std::map<std::string, std::set<std::string>> _connectionUris;
- mutable stdx::mutex _mutex;
+ mutable Mutex _mutex = MONGO_MAKE_LATCH("ConnectionRegistry::_mutex");
};
extern ConnectionRegistry connectionRegistry;
// This mutex helps the shell serialize output on exit, to avoid deadlocks at shutdown. So
// it also protects the global dbexitCalled.
-extern stdx::mutex& mongoProgramOutputMutex;
+extern Mutex& mongoProgramOutputMutex;
// Helper to tell if a file exists cross platform
// TODO: Remove this when we have a cross platform file utility library
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp
index d5d8e010d87..7537d710165 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -137,7 +137,7 @@ void safeClose(int fd) {
}
}
-stdx::mutex _createProcessMtx;
+Mutex _createProcessMtx;
} // namespace
ProgramOutputMultiplexer programOutputLogger;
@@ -242,7 +242,7 @@ void ProgramOutputMultiplexer::appendLine(int port,
ProcessId pid,
const std::string& name,
const std::string& line) {
- stdx::lock_guard<stdx::mutex> lk(mongoProgramOutputMutex);
+ stdx::lock_guard<Latch> lk(mongoProgramOutputMutex);
boost::iostreams::tee_device<std::ostream, std::stringstream> teeDevice(cout, _buffer);
boost::iostreams::stream<decltype(teeDevice)> teeStream(teeDevice);
if (port > 0) {
@@ -253,12 +253,12 @@ void ProgramOutputMultiplexer::appendLine(int port,
}
string ProgramOutputMultiplexer::str() const {
- stdx::lock_guard<stdx::mutex> lk(mongoProgramOutputMutex);
+ stdx::lock_guard<Latch> lk(mongoProgramOutputMutex);
return _buffer.str();
}
void ProgramOutputMultiplexer::clear() {
- stdx::lock_guard<stdx::mutex> lk(mongoProgramOutputMutex);
+ stdx::lock_guard<Latch> lk(mongoProgramOutputMutex);
_buffer.str("");
}
@@ -407,7 +407,7 @@ void ProgramRunner::start() {
//
// Holding the lock for the duration of those events prevents the leaks and thus the
// associated deadlocks.
- stdx::lock_guard<stdx::mutex> lk(_createProcessMtx);
+ stdx::lock_guard<Latch> lk(_createProcessMtx);
int status = pipe(pipeEnds);
if (status != 0) {
const auto ewd = errnoWithDescription();
diff --git a/src/mongo/shell/shell_utils_launcher.h b/src/mongo/shell/shell_utils_launcher.h
index bad1d2bdba7..c93e77ec34a 100644
--- a/src/mongo/shell/shell_utils_launcher.h
+++ b/src/mongo/shell/shell_utils_launcher.h
@@ -37,8 +37,8 @@
#include <vector>
#include "mongo/bson/bsonobj.h"
+#include "mongo/platform/mutex.h"
#include "mongo/platform/process_id.h"
-#include "mongo/stdx/mutex.h"
#include "mongo/stdx/thread.h"
#include "mongo/stdx/unordered_map.h"
#include "mongo/stdx/unordered_set.h"