diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2015-02-27 18:33:28 -0500 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2015-03-12 17:11:20 -0400 |
commit | 7cd9cf303c824478f0f6d60cadfcc1a25bdb21f2 (patch) | |
tree | ebeec8c3c2dc21359b941d95e2109e355542e65f /src/mongo/db/commands/dbhash.cpp | |
parent | 7ee3d124070db157181bc1b24f2b84913957c388 (diff) | |
download | mongo-7cd9cf303c824478f0f6d60cadfcc1a25bdb21f2.tar.gz |
SERVER-17310 Make mongo::mutex a typedef of boost::mutex and remove mongo::scoped_lock.
Diffstat (limited to 'src/mongo/db/commands/dbhash.cpp')
-rw-r--r-- | src/mongo/db/commands/dbhash.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp index 9d42024210d..bf0f43dcc9b 100644 --- a/src/mongo/db/commands/dbhash.cpp +++ b/src/mongo/db/commands/dbhash.cpp @@ -62,9 +62,7 @@ namespace mongo { // ---- - DBHashCmd::DBHashCmd() - : Command( "dbHash", false, "dbhash" ), - _cachedHashedMutex( "_cachedHashedMutex" ){ + DBHashCmd::DBHashCmd() : Command("dbHash", false, "dbhash") { } void DBHashCmd::addRequiredPrivileges(const std::string& dbname, @@ -75,11 +73,14 @@ namespace mongo { out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions)); } - string DBHashCmd::hashCollection( OperationContext* opCtx, Database* db, const string& fullCollectionName, bool* fromCache ) { - scoped_ptr<scoped_lock> cachedHashedLock; + std::string DBHashCmd::hashCollection(OperationContext* opCtx, + Database* db, + const std::string& fullCollectionName, + bool* fromCache) { + boost::unique_lock<boost::mutex> cachedHashedLock(_cachedHashedMutex, boost::defer_lock); if ( isCachable( fullCollectionName ) ) { - cachedHashedLock.reset( new scoped_lock( _cachedHashedMutex ) ); + cachedHashedLock.lock(); string hash = _cachedHashed[fullCollectionName]; if ( hash.size() > 0 ) { *fromCache = true; @@ -133,7 +134,7 @@ namespace mongo { md5_finish(&st, d); string hash = digestToString( d ); - if ( cachedHashedLock.get() ) { + if (cachedHashedLock.owns_lock()) { _cachedHashed[fullCollectionName] = hash; } @@ -225,7 +226,7 @@ namespace mongo { } void commit() { - scoped_lock lk( _dCmd->_cachedHashedMutex ); + boost::lock_guard<boost::mutex> lk( _dCmd->_cachedHashedMutex ); _dCmd->_cachedHashed.erase(_ns); } void rollback() { } |