diff options
Diffstat (limited to 'src/mongo/db')
30 files changed, 92 insertions, 96 deletions
diff --git a/src/mongo/db/catalog/cursor_manager.cpp b/src/mongo/db/catalog/cursor_manager.cpp index 3143c3382cf..b5bf0f49f73 100644 --- a/src/mongo/db/catalog/cursor_manager.cpp +++ b/src/mongo/db/catalog/cursor_manager.cpp @@ -141,8 +141,7 @@ namespace mongo { } GlobalCursorIdCache::GlobalCursorIdCache() - : _mutex( "GlobalCursorIdCache" ), - _nextId( 0 ), + : _nextId( 0 ), _secureRandom() { } @@ -150,7 +149,7 @@ namespace mongo { } int64_t GlobalCursorIdCache::nextSeed() { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); if ( !_secureRandom ) _secureRandom.reset(SecureRandom::create()); return _secureRandom->nextInt64(); @@ -159,7 +158,7 @@ namespace mongo { unsigned GlobalCursorIdCache::created( const std::string& ns ) { static const unsigned MAX_IDS = 1000 * 1000 * 1000; - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); fassert( 17359, _idToNS.size() < MAX_IDS ); @@ -177,7 +176,7 @@ namespace mongo { } void GlobalCursorIdCache::destroyed( unsigned id, const std::string& ns ) { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); invariant( ns == _idToNS[id] ); _idToNS.erase( id ); } @@ -195,7 +194,7 @@ namespace mongo { ns = pin.c()->ns(); } else { - SimpleMutex::scoped_lock lk(_mutex); + stdx::lock_guard<SimpleMutex> lk(_mutex); unsigned nsid = idFromCursorId(id); Map::const_iterator it = _idToNS.find(nsid); if (it == _idToNS.end()) { @@ -250,7 +249,7 @@ namespace mongo { // Compute the set of collection names that we have to time out cursors for. vector<string> todo; { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); for ( Map::const_iterator i = _idToNS.begin(); i != _idToNS.end(); ++i ) { if (globalCursorManager->ownsCursorId(cursorIdFromParts(i->first, 0))) { // Skip the global cursor manager, since we handle it above (and it's not @@ -317,8 +316,7 @@ namespace mongo { CursorManager::CursorManager( StringData ns ) - : _nss( ns ), - _mutex( "CursorManager" ) { + : _nss( ns ) { _collectionCacheRuntimeId = globalCursorIdCache->created( _nss.ns() ); _random.reset( new PseudoRandom( globalCursorIdCache->nextSeed() ) ); } @@ -330,7 +328,7 @@ namespace mongo { void CursorManager::invalidateAll(bool collectionGoingAway, const std::string& reason) { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); for ( ExecSet::iterator it = _nonCachedExecutors.begin(); it != _nonCachedExecutors.end(); @@ -407,7 +405,7 @@ namespace mongo { return; } - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); for ( ExecSet::iterator it = _nonCachedExecutors.begin(); it != _nonCachedExecutors.end(); @@ -426,7 +424,7 @@ namespace mongo { } std::size_t CursorManager::timeoutCursors( int millisSinceLastCall ) { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); vector<ClientCursor*> toDelete; @@ -448,18 +446,18 @@ namespace mongo { } void CursorManager::registerExecutor( PlanExecutor* exec ) { - SimpleMutex::scoped_lock lk(_mutex); + stdx::lock_guard<SimpleMutex> lk(_mutex); const std::pair<ExecSet::iterator, bool> result = _nonCachedExecutors.insert(exec); invariant(result.second); // make sure this was inserted } void CursorManager::deregisterExecutor( PlanExecutor* exec ) { - SimpleMutex::scoped_lock lk(_mutex); + stdx::lock_guard<SimpleMutex> lk(_mutex); _nonCachedExecutors.erase(exec); } ClientCursor* CursorManager::find( CursorId id, bool pin ) { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); CursorMap::const_iterator it = _cursors.find( id ); if ( it == _cursors.end() ) return NULL; @@ -476,7 +474,7 @@ namespace mongo { } void CursorManager::unpin( ClientCursor* cursor ) { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); invariant( cursor->isPinned() ); cursor->unsetPinned(); @@ -487,7 +485,7 @@ namespace mongo { } void CursorManager::getCursorIds( std::set<CursorId>* openCursors ) const { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); for ( CursorMap::const_iterator i = _cursors.begin(); i != _cursors.end(); ++i ) { ClientCursor* cc = i->second; @@ -496,7 +494,7 @@ namespace mongo { } size_t CursorManager::numCursors() const { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); return _cursors.size(); } @@ -512,19 +510,19 @@ namespace mongo { CursorId CursorManager::registerCursor( ClientCursor* cc ) { invariant( cc ); - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); CursorId id = _allocateCursorId_inlock(); _cursors[id] = cc; return id; } void CursorManager::deregisterCursor( ClientCursor* cc ) { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); _deregisterCursor_inlock( cc ); } bool CursorManager::eraseCursor(OperationContext* txn, CursorId id, bool checkAuth) { - SimpleMutex::scoped_lock lk( _mutex ); + stdx::lock_guard<SimpleMutex> lk( _mutex ); CursorMap::iterator it = _cursors.find( id ); if ( it == _cursors.end() ) { diff --git a/src/mongo/db/catalog/database_holder.cpp b/src/mongo/db/catalog/database_holder.cpp index 7ff6ea6d81b..bf1238db95f 100644 --- a/src/mongo/db/catalog/database_holder.cpp +++ b/src/mongo/db/catalog/database_holder.cpp @@ -84,7 +84,7 @@ namespace { const StringData db = _todb(ns); invariant(txn->lockState()->isDbLockedForMode(db, MODE_IS)); - SimpleMutex::scoped_lock lk(_m); + stdx::lock_guard<SimpleMutex> lk(_m); DBs::const_iterator it = _dbs.find(db); if (it != _dbs.end()) { return it->second; @@ -141,7 +141,7 @@ namespace { // no way we can insert two different databases for the same name. db = new Database(txn, dbname, entry); - SimpleMutex::scoped_lock lk(_m); + stdx::lock_guard<SimpleMutex> lk(_m); _dbs[dbname] = db; return db; @@ -154,7 +154,7 @@ namespace { const StringData dbName = _todb(ns); - SimpleMutex::scoped_lock lk(_m); + stdx::lock_guard<SimpleMutex> lk(_m); DBs::const_iterator it = _dbs.find(dbName); if (it == _dbs.end()) { @@ -171,7 +171,7 @@ namespace { bool DatabaseHolder::closeAll(OperationContext* txn, BSONObjBuilder& result, bool force) { invariant(txn->lockState()->isW()); - SimpleMutex::scoped_lock lk(_m); + stdx::lock_guard<SimpleMutex> lk(_m); set< string > dbs; for ( DBs::const_iterator i = _dbs.begin(); i != _dbs.end(); ++i ) { diff --git a/src/mongo/db/catalog/database_holder.h b/src/mongo/db/catalog/database_holder.h index 264a03b36b3..3238b886f01 100644 --- a/src/mongo/db/catalog/database_holder.h +++ b/src/mongo/db/catalog/database_holder.h @@ -45,7 +45,7 @@ namespace mongo { */ class DatabaseHolder { public: - DatabaseHolder() : _m("dbholder") { } + DatabaseHolder() = default; /** * Retrieves an already opened database or returns NULL. Must be called with the database @@ -81,7 +81,7 @@ namespace mongo { * lock is held, which would prevent database from disappearing or being created. */ void getAllShortNames( std::set<std::string>& all ) const { - SimpleMutex::scoped_lock lk(_m); + stdx::lock_guard<SimpleMutex> lk(_m); for( DBs::const_iterator j=_dbs.begin(); j!=_dbs.end(); ++j ) { all.insert( j->first ); } diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp index 1e2dc0a2439..698eb2fd406 100644 --- a/src/mongo/db/commands/authentication_commands.cpp +++ b/src/mongo/db/commands/authentication_commands.cpp @@ -100,7 +100,6 @@ namespace mongo { public: CmdGetNonce() : Command("getnonce"), - _randMutex("getnonce"), _random(SecureRandom::create()) { } @@ -130,7 +129,7 @@ namespace mongo { private: nonce64 getNextNonce() { - SimpleMutex::scoped_lock lk(_randMutex); + stdx::lock_guard<SimpleMutex> lk(_randMutex); return _random->nextInt64(); } diff --git a/src/mongo/db/commands/dbhash.h b/src/mongo/db/commands/dbhash.h index 35e5c9302fb..aa9a396b080 100644 --- a/src/mongo/db/commands/dbhash.h +++ b/src/mongo/db/commands/dbhash.h @@ -31,6 +31,7 @@ #pragma once #include "mongo/db/commands.h" +#include "mongo/stdx/mutex.h" namespace mongo { @@ -67,7 +68,7 @@ namespace mongo { std::string hashCollection( OperationContext* opCtx, Database* db, const std::string& fullCollectionName, bool* fromCache ); std::map<std::string,std::string> _cachedHashed; - mutex _cachedHashedMutex; + stdx::mutex _cachedHashedMutex; }; diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp index a8b19391d3c..aa3b8c9855a 100644 --- a/src/mongo/db/commands/fsync.cpp +++ b/src/mongo/db/commands/fsync.cpp @@ -92,7 +92,7 @@ namespace mongo { stdx::condition_variable_any _threadSync; stdx::condition_variable_any _unlockSync; - FSyncCommand() : Command( "fsync" ), m("lockfsync") { locked=false; pendingUnlock=false; } + FSyncCommand() : Command( "fsync" ) { locked=false; pendingUnlock=false; } virtual bool isWriteCommandForConfigServer() const { return false; } virtual bool slaveOk() const { return true; } virtual bool adminOnly() const { return true; } @@ -125,7 +125,7 @@ namespace mongo { return false; } - SimpleMutex::scoped_lock lk(m); + stdx::lock_guard<SimpleMutex> lk(m); err = ""; (new FSyncLockThread())->go(); @@ -211,16 +211,16 @@ namespace mongo { } unlockFsyncCmd; - SimpleMutex filesLockedFsync("filesLockedFsync"); + SimpleMutex filesLockedFsync; void FSyncLockThread::doRealWork() { - SimpleMutex::scoped_lock lkf(filesLockedFsync); + stdx::lock_guard<SimpleMutex> lkf(filesLockedFsync); OperationContextImpl txn; ScopedTransaction transaction(&txn, MODE_X); Lock::GlobalWrite global(txn.lockState()); // No WriteUnitOfWork needed - SimpleMutex::scoped_lock lk(fsyncCmd.m); + stdx::lock_guard<SimpleMutex> lk(fsyncCmd.m); invariant(!fsyncCmd.locked); // impossible to get here if locked is true try { @@ -271,7 +271,7 @@ namespace mongo { namespace { // @return true if unlocked bool unlockFsync() { - SimpleMutex::scoped_lock lk( fsyncCmd.m ); + stdx::lock_guard<SimpleMutex> lk( fsyncCmd.m ); if( !fsyncCmd.locked ) { return false; } diff --git a/src/mongo/db/concurrency/lock_manager.cpp b/src/mongo/db/concurrency/lock_manager.cpp index d082cc981ac..7a0e094ea30 100644 --- a/src/mongo/db/concurrency/lock_manager.cpp +++ b/src/mongo/db/concurrency/lock_manager.cpp @@ -399,7 +399,7 @@ namespace { // Migration time: lock each partition in turn and transfer its requests, if any while(partitioned()) { LockManager::Partition* partition = partitions.back(); - SimpleMutex::scoped_lock scopedLock(partition->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(partition->mutex); LockManager::Partition::Map::iterator it = partition->data.find(resourceId); if (it != partition->data.end()) { @@ -459,7 +459,7 @@ namespace { // For intent modes, try the PartitionedLockHead if (request->partitioned) { Partition* partition = _getPartition(request); - SimpleMutex::scoped_lock scopedLock(partition->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(partition->mutex); // Fast path for intent locks PartitionedLockHead* partitionedLock = partition->find(resId); @@ -475,7 +475,7 @@ namespace { // Use regular LockHead, maybe start partitioning LockBucket* bucket = _getBucket(resId); - SimpleMutex::scoped_lock scopedLock(bucket->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(bucket->mutex); LockHead* lock = bucket->findOrInsert(resId); @@ -483,7 +483,7 @@ namespace { if (request->partitioned && !(lock->grantedModes & (~intentModes)) && !lock->conflictModes) { Partition* partition = _getPartition(request); - SimpleMutex::scoped_lock scopedLock(partition->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(partition->mutex); PartitionedLockHead* partitionedLock = partition->findOrInsert(resId); invariant(partitionedLock); lock->partitions.push_back(partition); @@ -524,7 +524,7 @@ namespace { LockConflictsTable[newMode]); LockBucket* bucket = _getBucket(resId); - SimpleMutex::scoped_lock scopedLock(bucket->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(bucket->mutex); LockBucket::Map::iterator it = bucket->data.find(resId); invariant(it != bucket->data.end()); @@ -595,7 +595,7 @@ namespace { invariant(request->status == LockRequest::STATUS_GRANTED || request->status == LockRequest::STATUS_CONVERTING); Partition* partition = _getPartition(request); - SimpleMutex::scoped_lock scopedLock(partition->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(partition->mutex); // Fast path: still partitioned. if (request->partitionedLock) { request->partitionedLock->grantedList.remove(request); @@ -608,7 +608,7 @@ namespace { LockHead* lock = request->lock; LockBucket* bucket = _getBucket(lock->resourceId); - SimpleMutex::scoped_lock scopedLock(bucket->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(bucket->mutex); if (request->status == LockRequest::STATUS_GRANTED) { // This releases a currently held lock and is the most common path, so it should be @@ -668,7 +668,7 @@ namespace { LockHead* lock = request->lock; LockBucket* bucket = _getBucket(lock->resourceId); - SimpleMutex::scoped_lock scopedLock(bucket->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(bucket->mutex); lock->incGrantedModeCount(newMode); lock->decGrantedModeCount(request->mode); @@ -681,7 +681,7 @@ namespace { size_t deletedLockHeads = 0; for (unsigned i = 0; i < _numLockBuckets; i++) { LockBucket* bucket = &_lockBuckets[i]; - SimpleMutex::scoped_lock scopedLock(bucket->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(bucket->mutex); LockBucket::Map::iterator it = bucket->data.begin(); while (it != bucket->data.end()) { @@ -821,7 +821,7 @@ namespace { for (unsigned i = 0; i < _numLockBuckets; i++) { LockBucket* bucket = &_lockBuckets[i]; - SimpleMutex::scoped_lock scopedLock(bucket->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(bucket->mutex); if (!bucket->data.empty()) { _dumpBucket(bucket); @@ -971,7 +971,7 @@ namespace { void DeadlockDetector::_processNextNode(const UnprocessedNode& node) { // Locate the request LockManager::LockBucket* bucket = _lockMgr._getBucket(node.resId); - SimpleMutex::scoped_lock scopedLock(bucket->mutex); + stdx::lock_guard<SimpleMutex> scopedLock(bucket->mutex); LockManager::LockBucket::Map::const_iterator iter = bucket->data.find(node.resId); if (iter == bucket->data.end()) { diff --git a/src/mongo/db/concurrency/lock_manager.h b/src/mongo/db/concurrency/lock_manager.h index 1d8c054152b..badad082214 100644 --- a/src/mongo/db/concurrency/lock_manager.h +++ b/src/mongo/db/concurrency/lock_manager.h @@ -130,7 +130,6 @@ namespace mongo { // These types describe the locks hash table struct LockBucket { - LockBucket() : mutex("LockManager") { } SimpleMutex mutex; typedef unordered_map<ResourceId, LockHead*> Map; Map data; @@ -141,7 +140,6 @@ namespace mongo { // modes and potentially other modes that don't conflict with themselves. This avoids // contention on the regular LockHead in the lock manager. struct Partition { - Partition() : mutex("LockManager") { } PartitionedLockHead* find(ResourceId resId); PartitionedLockHead* findOrInsert(ResourceId resId); typedef unordered_map<ResourceId, PartitionedLockHead*> Map; diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 4969640bea7..b16c9c8ba8b 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -113,6 +113,7 @@ #include "mongo/util/signal_handlers.h" #include "mongo/util/stacktrace.h" #include "mongo/util/startup_test.h" +#include "mongo/util/static_observer.h" #include "mongo/util/text.h" #include "mongo/util/time_support.h" #include "mongo/util/version.h" diff --git a/src/mongo/db/global_timestamp.cpp b/src/mongo/db/global_timestamp.cpp index 6fd17da2d28..536d9d17b98 100644 --- a/src/mongo/db/global_timestamp.cpp +++ b/src/mongo/db/global_timestamp.cpp @@ -29,12 +29,12 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault #include "mongo/db/global_timestamp.h" +#include "mongo/stdx/mutex.h" #include "mongo/stdx/thread.h" -#include "mongo/util/concurrency/mutex.h" #include "mongo/util/log.h" namespace { - mongo::mutex globalTimestampMutex; + mongo::stdx::mutex globalTimestampMutex; mongo::Timestamp globalTimestamp(0, 0); bool skewed(const mongo::Timestamp& val) { diff --git a/src/mongo/db/instance.h b/src/mongo/db/instance.h index e7aa31b9f86..097b62d743b 100644 --- a/src/mongo/db/instance.h +++ b/src/mongo/db/instance.h @@ -50,7 +50,7 @@ namespace mongo { 7 = log a few reads, and all writes. */ int level; - mongo::mutex mutex; + stdx::mutex mutex; void openFile(); public: diff --git a/src/mongo/db/range_deleter.h b/src/mongo/db/range_deleter.h index db56a86576b..eaf8fa35e1d 100644 --- a/src/mongo/db/range_deleter.h +++ b/src/mongo/db/range_deleter.h @@ -39,6 +39,7 @@ #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" #include "mongo/db/write_concern_options.h" +#include "mongo/stdx/mutex.h" #include "mongo/stdx/thread.h" #include "mongo/util/concurrency/mutex.h" #include "mongo/util/concurrency/synchronization.h" @@ -203,7 +204,7 @@ namespace mongo { std::unique_ptr<stdx::thread> _worker; // Protects _stopRequested. - mutable mutex _stopMutex; + mutable stdx::mutex _stopMutex; // If set, no other delete taks should be accepted. bool _stopRequested; @@ -214,7 +215,7 @@ namespace mongo { stdx::condition_variable _nothingInProgressCV; // Protects all the data structure below this. - mutable mutex _queueMutex; + mutable stdx::mutex _queueMutex; // _taskQueue has a task ready to work on. stdx::condition_variable _taskQueueNotEmptyCV; @@ -240,7 +241,7 @@ namespace mongo { size_t _deletesInProgress; // Protects _statsHistory - mutable mutex _statsHistoryMutex; + mutable stdx::mutex _statsHistoryMutex; std::deque<DeleteJobStats*> _statsHistory; }; diff --git a/src/mongo/db/range_deleter_mock_env.h b/src/mongo/db/range_deleter_mock_env.h index b4892b99f70..bba49a360e4 100644 --- a/src/mongo/db/range_deleter_mock_env.h +++ b/src/mongo/db/range_deleter_mock_env.h @@ -33,6 +33,7 @@ #include <string> #include "mongo/db/range_deleter.h" +#include "mongo/stdx/mutex.h" namespace mongo { @@ -139,14 +140,14 @@ namespace mongo { // mutex acquisition ordering: // _envStatMutex -> _pauseDeleteMutex -> _deleteListMutex -> _cursorMapMutex - mutable mutex _deleteListMutex; + mutable stdx::mutex _deleteListMutex; std::vector<DeletedRange> _deleteList; - mutex _cursorMapMutex; + stdx::mutex _cursorMapMutex; std::map<std::string, std::set<CursorId> > _cursorMap; // Protects _pauseDelete & _pausedCount - mutex _pauseDeleteMutex; + stdx::mutex _pauseDeleteMutex; stdx::condition_variable _pausedCV; bool _pauseDelete; @@ -156,7 +157,7 @@ namespace mongo { stdx::condition_variable _pausedDeleteChangeCV; // Protects all variables below this line. - mutex _envStatMutex; + stdx::mutex _envStatMutex; // Keeps track of the number of times getCursorIds was called. uint64_t _getCursorsCallCount; diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 5b3d48fbc21..26708ee8de7 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -103,7 +103,7 @@ namespace { // Synchronizes the section where a new Timestamp is generated and when it actually // appears in the oplog. - mongo::mutex newOpMutex; + stdx::mutex newOpMutex; stdx::condition_variable newTimestampNotifier; static std::string _oplogCollectionName; diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index 545dea83f9d..2bfe05728fe 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -365,7 +365,7 @@ namespace { // We must grab this because we're going to grab write locks later. // We hold this mutex the entire time we're writing; it doesn't matter // because all readers are blocked anyway. - SimpleMutex::scoped_lock fsynclk(filesLockedFsync); + stdx::lock_guard<SimpleMutex> fsynclk(filesLockedFsync); // stop all readers until we're done Lock::ParallelBatchWriterMode pbwm(txn->lockState()); diff --git a/src/mongo/db/stats/snapshots.h b/src/mongo/db/stats/snapshots.h index 9c29e7d5eb6..6f3b90e0cb9 100644 --- a/src/mongo/db/stats/snapshots.h +++ b/src/mongo/db/stats/snapshots.h @@ -96,7 +96,7 @@ namespace mongo { StatusWith<SnapshotDiff> computeDelta(); private: - mongo::mutex _lock; + stdx::mutex _lock; static const int kNumSnapshots = 2; SnapshotData _snapshots[kNumSnapshots]; int _loc; diff --git a/src/mongo/db/stats/top.cpp b/src/mongo/db/stats/top.cpp index af793f9401a..903378e1834 100644 --- a/src/mongo/db/stats/top.cpp +++ b/src/mongo/db/stats/top.cpp @@ -80,7 +80,7 @@ namespace { return; //cout << "record: " << ns << "\t" << op << "\t" << command << endl; - SimpleMutex::scoped_lock lk(_lock); + stdx::lock_guard<SimpleMutex> lk(_lock); if ( ( command || op == dbQuery ) && ns == _lastDropped ) { _lastDropped = ""; @@ -138,18 +138,18 @@ namespace { } void Top::collectionDropped( StringData ns ) { - SimpleMutex::scoped_lock lk(_lock); + stdx::lock_guard<SimpleMutex> lk(_lock); _usage.erase(ns); _lastDropped = ns.toString(); } void Top::cloneMap(Top::UsageMap& out) const { - SimpleMutex::scoped_lock lk(_lock); + stdx::lock_guard<SimpleMutex> lk(_lock); out = _usage; } void Top::append( BSONObjBuilder& b ) { - SimpleMutex::scoped_lock lk( _lock ); + stdx::lock_guard<SimpleMutex> lk( _lock ); _appendToUsageMap( b, _usage ); } diff --git a/src/mongo/db/stats/top.h b/src/mongo/db/stats/top.h index 8d5c4919f03..d71605e8ef4 100644 --- a/src/mongo/db/stats/top.h +++ b/src/mongo/db/stats/top.h @@ -46,7 +46,7 @@ namespace mongo { public: static Top& get(ServiceContext* service); - Top() : _lock("Top") { } + Top() = default; struct UsageData { UsageData() : time(0), count(0) {} diff --git a/src/mongo/db/storage/mmap_v1/dur.cpp b/src/mongo/db/storage/mmap_v1/dur.cpp index ec76e172bc5..a596bba061f 100644 --- a/src/mongo/db/storage/mmap_v1/dur.cpp +++ b/src/mongo/db/storage/mmap_v1/dur.cpp @@ -534,7 +534,7 @@ namespace { void DurableImpl::declareWriteIntents( const std::vector<std::pair<void*, unsigned> >& intents) { typedef std::vector<std::pair<void*, unsigned> > Intents; - SimpleMutex::scoped_lock lk(commitJob.groupCommitMutex); + stdx::lock_guard<SimpleMutex> lk(commitJob.groupCommitMutex); for (Intents::const_iterator it(intents.begin()), end(intents.end()); it != end; ++it) { commitJob.note(it->first, it->second); } diff --git a/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp b/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp index 666a6c4a2eb..27e7681b17c 100644 --- a/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp @@ -63,7 +63,6 @@ namespace dur { CommitJob::CommitJob() : - groupCommitMutex("groupCommit"), _hasWritten(false), _lastNotedPos(0), _bytes(0) { @@ -75,7 +74,7 @@ namespace dur { } void CommitJob::noteOp(shared_ptr<DurOp> p) { - SimpleMutex::scoped_lock lk(groupCommitMutex); + stdx::lock_guard<SimpleMutex> lk(groupCommitMutex); _hasWritten = true; _durOps.push_back(p); } diff --git a/src/mongo/db/storage/mmap_v1/dur_journal.cpp b/src/mongo/db/storage/mmap_v1/dur_journal.cpp index 8eeb229d5bc..a76ade46128 100644 --- a/src/mongo/db/storage/mmap_v1/dur_journal.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_journal.cpp @@ -160,7 +160,7 @@ namespace mongo { namespace { SecureRandom* mySecureRandom = NULL; - mongo::mutex mySecureRandomMutex; + stdx::mutex mySecureRandomMutex; int64_t getMySecureRandomNumber() { stdx::lock_guard<stdx::mutex> lk( mySecureRandomMutex ); if ( ! mySecureRandom ) @@ -190,8 +190,7 @@ namespace mongo { const unsigned long long LsnShutdownSentinel = ~((unsigned long long)0); - Journal::Journal() : - _curLogFileMutex("JournalLfMutex") { + Journal::Journal() { _written = 0; _nextFileNumber = 0; _curLogFile = 0; @@ -280,7 +279,7 @@ namespace mongo { if( _log ) log() << "journalCleanup..." << endl; try { - SimpleMutex::scoped_lock lk(_curLogFileMutex); + stdx::lock_guard<SimpleMutex> lk(_curLogFileMutex); closeCurrentJournalFile(); removeJournalFiles(); } @@ -561,7 +560,7 @@ namespace mongo { void Journal::open() { verify( MongoFile::notifyPreFlush == preFlush ); - SimpleMutex::scoped_lock lk(_curLogFileMutex); + stdx::lock_guard<SimpleMutex> lk(_curLogFileMutex); _open(); } @@ -694,8 +693,6 @@ namespace mongo { void Journal::_rotate() { - _curLogFileMutex.dassertLocked(); - if ( inShutdown() || !_curLogFile ) return; @@ -777,7 +774,7 @@ namespace mongo { } try { - SimpleMutex::scoped_lock lk(_curLogFileMutex); + stdx::lock_guard<SimpleMutex> lk(_curLogFileMutex); // must already be open -- so that _curFileId is correct for previous buffer building verify( _curLogFile ); diff --git a/src/mongo/db/storage/mmap_v1/dur_journalimpl.h b/src/mongo/db/storage/mmap_v1/dur_journalimpl.h index 7664e1f5265..365f38aec71 100644 --- a/src/mongo/db/storage/mmap_v1/dur_journalimpl.h +++ b/src/mongo/db/storage/mmap_v1/dur_journalimpl.h @@ -65,7 +65,7 @@ namespace mongo { unsigned long long curFileId() const { return _curFileId; } void assureLogFileOpen() { - SimpleMutex::scoped_lock lk(_curLogFileMutex); + stdx::lock_guard<SimpleMutex> lk(_curLogFileMutex); if( _curLogFile == 0 ) _open(); } diff --git a/src/mongo/db/storage/mmap_v1/dur_recover.h b/src/mongo/db/storage/mmap_v1/dur_recover.h index 1e22a693ed6..886f278a66a 100644 --- a/src/mongo/db/storage/mmap_v1/dur_recover.h +++ b/src/mongo/db/storage/mmap_v1/dur_recover.h @@ -85,7 +85,7 @@ namespace mongo { // Set of memory mapped files and a mutex to protect them - mongo::mutex _mx; + stdx::mutex _mx; std::list<std::shared_ptr<DurableMappedFile> > _mmfs; // Are we in recovery or WRITETODATAFILES diff --git a/src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp b/src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp index e78c29281c7..e32c0b15ffe 100644 --- a/src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp +++ b/src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp @@ -107,7 +107,7 @@ namespace mongo { } } - extern mutex mapViewMutex; + extern stdx::mutex mapViewMutex; __declspec(noinline) void PointerToDurableMappedFile::makeChunkWritable(size_t chunkno) { stdx::lock_guard<stdx::mutex> lkPrivateViews(_m); diff --git a/src/mongo/db/storage/mmap_v1/durable_mapped_file.h b/src/mongo/db/storage/mmap_v1/durable_mapped_file.h index 0ebbd9dd7c9..c4cfb5a6131 100644 --- a/src/mongo/db/storage/mmap_v1/durable_mapped_file.h +++ b/src/mongo/db/storage/mmap_v1/durable_mapped_file.h @@ -33,6 +33,7 @@ #include "mongo/db/storage/mmap_v1/mmap.h" #include "mongo/db/storage/paths.h" +#include "mongo/stdx/mutex.h" namespace mongo { @@ -197,7 +198,7 @@ namespace mongo { DurableMappedFile* find(void *p, /*out*/ size_t& ofs); /** for doing many finds in a row with one lock operation */ - mutex& _mutex() { return _m; } + stdx::mutex& _mutex() { return _m; } /** not-threadsafe, caller must hold _mutex() */ DurableMappedFile* find_inlock(void *p, /*out*/ size_t& ofs); @@ -224,7 +225,7 @@ namespace mongo { // Protects internal consistency of data structure // Lock Ordering: // Must be taken before MapViewMutex if both are taken to prevent deadlocks - mutex _m; + stdx::mutex _m; std::map<void*, DurableMappedFile*> _views; #ifdef _WIN32 diff --git a/src/mongo/db/storage/mmap_v1/file_allocator.cpp b/src/mongo/db/storage/mmap_v1/file_allocator.cpp index f785fa2a456..bedd7d9e03d 100644 --- a/src/mongo/db/storage/mmap_v1/file_allocator.cpp +++ b/src/mongo/db/storage/mmap_v1/file_allocator.cpp @@ -78,7 +78,7 @@ namespace mongo { // unique number for temporary file names unsigned long long FileAllocator::_uniqueNumber = 0; - static SimpleMutex _uniqueNumberMutex( "uniqueNumberMutex" ); + static SimpleMutex _uniqueNumberMutex; MONGO_FP_DECLARE(allocateDiskFull); @@ -336,7 +336,7 @@ namespace mongo { { // increment temporary file name counter // TODO: SERVER-6055 -- Unify temporary file name selection - SimpleMutex::scoped_lock lk(_uniqueNumberMutex); + stdx::lock_guard<SimpleMutex> lk(_uniqueNumberMutex); thisUniqueNumber = _uniqueNumber; ++_uniqueNumber; } @@ -354,7 +354,7 @@ namespace mongo { { // initialize unique temporary file name counter // TODO: SERVER-6055 -- Unify temporary file name selection - SimpleMutex::scoped_lock lk(_uniqueNumberMutex); + stdx::lock_guard<SimpleMutex> lk(_uniqueNumberMutex); _uniqueNumber = curTimeMicros64(); } while( 1 ) { diff --git a/src/mongo/db/storage/mmap_v1/file_allocator.h b/src/mongo/db/storage/mmap_v1/file_allocator.h index d42850f1aa0..d3f9b6cceda 100644 --- a/src/mongo/db/storage/mmap_v1/file_allocator.h +++ b/src/mongo/db/storage/mmap_v1/file_allocator.h @@ -91,7 +91,7 @@ namespace mongo { // generate a unique name for temporary files std::string makeTempFileName( boost::filesystem::path root ); - mutable mongo::mutex _pendingMutex; + mutable stdx::mutex _pendingMutex; mutable stdx::condition_variable _pendingUpdated; std::list< std::string > _pending; diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h index c2343205dc9..8253d0f87a3 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h @@ -41,7 +41,7 @@ #include "mongo/db/storage/mmap_v1/extent_manager.h" #include "mongo/db/storage/mmap_v1/record_access_tracker.h" #include "mongo/platform/atomic_word.h" -#include "mongo/util/concurrency/mutex.h" +#include "mongo/stdx/mutex.h" namespace mongo { @@ -238,7 +238,7 @@ namespace mongo { void push_back(DataFile* val); private: - mutex _writersMutex; + stdx::mutex _writersMutex; AtomicInt32 _size; // number of files in the array DataFile* _files[DiskLoc::MaxFiles]; }; diff --git a/src/mongo/db/storage/mmap_v1/mmap_windows.cpp b/src/mongo/db/storage/mmap_v1/mmap_windows.cpp index 2b57dc4672b..2969028575a 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_windows.cpp +++ b/src/mongo/db/storage/mmap_v1/mmap_windows.cpp @@ -35,6 +35,7 @@ #include "mongo/db/storage/mmap_v1/durable_mapped_file.h" #include "mongo/db/storage/mmap_v1/file_allocator.h" +#include "mongo/stdx/mutex.h" #include "mongo/util/log.h" #include "mongo/util/processinfo.h" #include "mongo/util/text.h" @@ -69,7 +70,7 @@ namespace mongo { // 2. Prevents calls to VirtualProtect while we remapping files. // Lock Ordering: // - If taken, must be after previewViews._m to prevent deadlocks - mutex mapViewMutex; + stdx::mutex mapViewMutex; MAdvise::MAdvise(void *,unsigned, Advice) { } MAdvise::~MAdvise() { } @@ -84,7 +85,7 @@ namespace mongo { // placing memory mapped files in memory // Lock Ordering: // No restrictions - static SimpleMutex _nextMemoryMappedFileLocationMutex("nextMemoryMappedFileLocationMutex"); + static SimpleMutex _nextMemoryMappedFileLocationMutex; unsigned long long AlignNumber(unsigned long long number, unsigned long long granularity) { @@ -95,7 +96,7 @@ namespace mongo { if (4 == sizeof(void*)) { return 0; } - SimpleMutex::scoped_lock lk(_nextMemoryMappedFileLocationMutex); + stdx::lock_guard<SimpleMutex> lk(_nextMemoryMappedFileLocationMutex); static unsigned long long granularity = 0; @@ -359,7 +360,7 @@ namespace mongo { return view; } - extern mutex mapViewMutex; + extern stdx::mutex mapViewMutex; void* MemoryMappedFile::createPrivateMap() { verify( maphandle ); diff --git a/src/mongo/db/storage/mmap_v1/record_access_tracker.cpp b/src/mongo/db/storage/mmap_v1/record_access_tracker.cpp index d0ca6887127..ab77ad69b08 100644 --- a/src/mongo/db/storage/mmap_v1/record_access_tracker.cpp +++ b/src/mongo/db/storage/mmap_v1/record_access_tracker.cpp @@ -227,8 +227,7 @@ namespace mongo { // Rolling // - RecordAccessTracker::Rolling::Rolling() - : _lock( "ps::Rolling" ){ + RecordAccessTracker::Rolling::Rolling() { _curSlice = 0; _lastRotate = Listener::getElapsedTimeMillis(); } @@ -236,7 +235,7 @@ namespace mongo { bool RecordAccessTracker::Rolling::access(size_t region, short offset, bool doHalf) { int regionHash = hash(region); - SimpleMutex::scoped_lock lk(_lock); + stdx::lock_guard<SimpleMutex> lk(_lock); static int rarelyCount = 0; if (rarelyCount++ % (2048 / BigHashSize) == 0) { |