From d7d1fdb75966c684e9a42150e6e9b69c4a10ee08 Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Wed, 10 Jun 2015 18:08:48 -0400 Subject: SERVER-17308 Replace boost::scoped_ptr with std::unique_ptr --- src/mongo/db/storage/kv/kv_catalog.cpp | 15 ++++--- src/mongo/db/storage/kv/kv_catalog.h | 1 - .../db/storage/kv/kv_collection_catalog_entry.h | 2 +- src/mongo/db/storage/kv/kv_engine_test_harness.cpp | 47 +++++++++++----------- src/mongo/db/storage/kv/kv_storage_engine.h | 7 ++-- 5 files changed, 34 insertions(+), 38 deletions(-) (limited to 'src/mongo/db/storage/kv') diff --git a/src/mongo/db/storage/kv/kv_catalog.cpp b/src/mongo/db/storage/kv/kv_catalog.cpp index 53382bd8b93..6797cdf5bff 100644 --- a/src/mongo/db/storage/kv/kv_catalog.cpp +++ b/src/mongo/db/storage/kv/kv_catalog.cpp @@ -32,7 +32,6 @@ #include "mongo/db/storage/kv/kv_catalog.h" -#include #include #include "mongo/db/concurrency/d_concurrency.h" @@ -54,7 +53,7 @@ namespace { const ResourceId resourceIdCatalogMetadata(RESOURCE_METADATA, 1ULL); } - using boost::scoped_ptr; + using std::unique_ptr; using std::string; class KVCatalog::AddIdentChange : public RecoveryUnit::Change { @@ -107,7 +106,7 @@ namespace { std::string KVCatalog::_newRand() { return str::stream() - << boost::scoped_ptr(SecureRandom::create())->nextInt64(); + << std::unique_ptr(SecureRandom::create())->nextInt64(); } bool KVCatalog::_hasEntryCollidingWithRand() const { @@ -162,7 +161,7 @@ namespace { invariant( opCtx->lockState() == NULL || opCtx->lockState()->isDbLockedForMode( nsToDatabaseSubstring(ns), MODE_X ) ); - boost::scoped_ptr rLk; + std::unique_ptr rLk; if (!_isRsThreadSafe && opCtx->lockState()) { rLk.reset(new Lock::ResourceLock(opCtx->lockState(), resourceIdCatalogMetadata, @@ -219,7 +218,7 @@ namespace { StringData ns, RecordId* out ) const { - boost::scoped_ptr rLk; + std::unique_ptr rLk; if (!_isRsThreadSafe && opCtx->lockState()) { rLk.reset(new Lock::ResourceLock(opCtx->lockState(), resourceIdCatalogMetadata, @@ -266,7 +265,7 @@ namespace { StringData ns, BSONCollectionCatalogEntry::MetaData& md ) { - boost::scoped_ptr rLk; + std::unique_ptr rLk; if (!_isRsThreadSafe && opCtx->lockState()) { rLk.reset(new Lock::ResourceLock(opCtx->lockState(), resourceIdCatalogMetadata, @@ -320,7 +319,7 @@ namespace { StringData toNS, bool stayTemp ) { - boost::scoped_ptr rLk; + std::unique_ptr rLk; if (!_isRsThreadSafe && opCtx->lockState()) { rLk.reset(new Lock::ResourceLock(opCtx->lockState(), resourceIdCatalogMetadata, @@ -371,7 +370,7 @@ namespace { StringData ns ) { invariant( opCtx->lockState() == NULL || opCtx->lockState()->isDbLockedForMode( nsToDatabaseSubstring(ns), MODE_X ) ); - boost::scoped_ptr rLk; + std::unique_ptr rLk; if (!_isRsThreadSafe && opCtx->lockState()) { rLk.reset(new Lock::ResourceLock(opCtx->lockState(), resourceIdCatalogMetadata, diff --git a/src/mongo/db/storage/kv/kv_catalog.h b/src/mongo/db/storage/kv/kv_catalog.h index 359fa4cfbdb..cbdbfc515bc 100644 --- a/src/mongo/db/storage/kv/kv_catalog.h +++ b/src/mongo/db/storage/kv/kv_catalog.h @@ -33,7 +33,6 @@ #include #include -#include #include #include "mongo/base/string_data.h" diff --git a/src/mongo/db/storage/kv/kv_collection_catalog_entry.h b/src/mongo/db/storage/kv/kv_collection_catalog_entry.h index 28392db8a61..963c9d623f9 100644 --- a/src/mongo/db/storage/kv/kv_collection_catalog_entry.h +++ b/src/mongo/db/storage/kv/kv_collection_catalog_entry.h @@ -89,7 +89,7 @@ namespace mongo { KVEngine* _engine; // not owned KVCatalog* _catalog; // not owned std::string _ident; - boost::scoped_ptr _recordStore; // owned + std::unique_ptr _recordStore; // owned }; } diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp index f2438689f8e..36aeefcf2c4 100644 --- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp +++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp @@ -30,7 +30,6 @@ #include "mongo/db/storage/kv/kv_engine_test_harness.h" -#include #include "mongo/db/operation_context_noop.h" #include "mongo/db/index/index_descriptor.h" @@ -42,7 +41,7 @@ namespace mongo { - using boost::scoped_ptr; + using std::unique_ptr; using std::string; namespace { @@ -55,12 +54,12 @@ namespace mongo { } TEST( KVEngineTestHarness, SimpleRS1 ) { - scoped_ptr helper( KVHarnessHelper::create() ); + unique_ptr helper( KVHarnessHelper::create() ); KVEngine* engine = helper->getEngine(); ASSERT( engine ); string ns = "a.b"; - scoped_ptr rs; + unique_ptr rs; { MyOperationContext opCtx( engine ); ASSERT_OK( engine->createRecordStore( &opCtx, ns, ns, CollectionOptions() ) ); @@ -94,7 +93,7 @@ namespace mongo { } TEST( KVEngineTestHarness, Restart1 ) { - scoped_ptr helper( KVHarnessHelper::create() ); + unique_ptr helper( KVHarnessHelper::create() ); KVEngine* engine = helper->getEngine(); ASSERT( engine ); @@ -103,7 +102,7 @@ namespace mongo { // 'loc' holds location of "abc" and is referenced after restarting engine. RecordId loc; { - scoped_ptr rs; + unique_ptr rs; { MyOperationContext opCtx( engine ); ASSERT_OK( engine->createRecordStore( &opCtx, ns, ns, CollectionOptions() ) ); @@ -129,7 +128,7 @@ namespace mongo { engine = helper->restartEngine(); { - scoped_ptr rs; + unique_ptr rs; MyOperationContext opCtx( engine ); rs.reset( engine->getRecordStore( &opCtx, ns, ns, CollectionOptions() ) ); ASSERT_EQUALS( string("abc"), rs->dataFor( &opCtx, loc ).data() ); @@ -139,13 +138,13 @@ namespace mongo { TEST( KVEngineTestHarness, SimpleSorted1 ) { - scoped_ptr helper( KVHarnessHelper::create() ); + unique_ptr helper( KVHarnessHelper::create() ); KVEngine* engine = helper->getEngine(); ASSERT( engine ); string ident = "abc"; IndexDescriptor desc( NULL, "", BSON( "key" << BSON( "a" << 1 ) ) ); - scoped_ptr sorted; + unique_ptr sorted; { MyOperationContext opCtx( engine ); ASSERT_OK( engine->createSortedDataInterface( &opCtx, ident, &desc ) ); @@ -168,11 +167,11 @@ namespace mongo { } TEST( KVCatalogTest, Coll1 ) { - scoped_ptr helper( KVHarnessHelper::create() ); + unique_ptr helper( KVHarnessHelper::create() ); KVEngine* engine = helper->getEngine(); - scoped_ptr rs; - scoped_ptr catalog; + unique_ptr rs; + unique_ptr catalog; { MyOperationContext opCtx( engine ); WriteUnitOfWork uow( &opCtx ); @@ -212,11 +211,11 @@ namespace mongo { TEST( KVCatalogTest, Idx1 ) { - scoped_ptr helper( KVHarnessHelper::create() ); + unique_ptr helper( KVHarnessHelper::create() ); KVEngine* engine = helper->getEngine(); - scoped_ptr rs; - scoped_ptr catalog; + unique_ptr rs; + unique_ptr catalog; { MyOperationContext opCtx( engine ); WriteUnitOfWork uow( &opCtx ); @@ -284,11 +283,11 @@ namespace mongo { } TEST( KVCatalogTest, DirectoryPerDb1 ) { - scoped_ptr helper( KVHarnessHelper::create() ); + unique_ptr helper( KVHarnessHelper::create() ); KVEngine* engine = helper->getEngine(); - scoped_ptr rs; - scoped_ptr catalog; + unique_ptr rs; + unique_ptr catalog; { MyOperationContext opCtx( engine ); WriteUnitOfWork uow( &opCtx ); @@ -326,11 +325,11 @@ namespace mongo { } TEST( KVCatalogTest, Split1 ) { - scoped_ptr helper( KVHarnessHelper::create() ); + unique_ptr helper( KVHarnessHelper::create() ); KVEngine* engine = helper->getEngine(); - scoped_ptr rs; - scoped_ptr catalog; + unique_ptr rs; + unique_ptr catalog; { MyOperationContext opCtx( engine ); WriteUnitOfWork uow( &opCtx ); @@ -368,11 +367,11 @@ namespace mongo { } TEST( KVCatalogTest, DirectoryPerAndSplit1 ) { - scoped_ptr helper( KVHarnessHelper::create() ); + unique_ptr helper( KVHarnessHelper::create() ); KVEngine* engine = helper->getEngine(); - scoped_ptr rs; - scoped_ptr catalog; + unique_ptr rs; + unique_ptr catalog; { MyOperationContext opCtx( engine ); WriteUnitOfWork uow( &opCtx ); diff --git a/src/mongo/db/storage/kv/kv_storage_engine.h b/src/mongo/db/storage/kv/kv_storage_engine.h index b6f33c2d7b5..f8106959dc3 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine.h +++ b/src/mongo/db/storage/kv/kv_storage_engine.h @@ -33,7 +33,6 @@ #include #include -#include #include #include "mongo/db/storage/kv/kv_catalog.h" @@ -103,12 +102,12 @@ namespace mongo { KVStorageEngineOptions _options; // This must be the first member so it is destroyed last. - boost::scoped_ptr _engine; + std::unique_ptr _engine; const bool _supportsDocLocking; - boost::scoped_ptr _catalogRecordStore; - boost::scoped_ptr _catalog; + std::unique_ptr _catalogRecordStore; + std::unique_ptr _catalog; typedef std::map DBMap; DBMap _dbs; -- cgit v1.2.1