diff options
Diffstat (limited to 'src/mongo/db/catalog/index_catalog_entry.h')
-rw-r--r-- | src/mongo/db/catalog/index_catalog_entry.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mongo/db/catalog/index_catalog_entry.h b/src/mongo/db/catalog/index_catalog_entry.h index eb54f065e7b..192788e3948 100644 --- a/src/mongo/db/catalog/index_catalog_entry.h +++ b/src/mongo/db/catalog/index_catalog_entry.h @@ -156,8 +156,8 @@ public: class IndexCatalogEntryContainer { public: - typedef std::vector<std::unique_ptr<IndexCatalogEntry>>::const_iterator const_iterator; - typedef std::vector<std::unique_ptr<IndexCatalogEntry>>::const_iterator iterator; + typedef std::vector<std::shared_ptr<IndexCatalogEntry>>::const_iterator const_iterator; + typedef std::vector<std::shared_ptr<IndexCatalogEntry>>::const_iterator iterator; const_iterator begin() const { return _entries.begin(); @@ -182,6 +182,11 @@ public: IndexCatalogEntry* find(const std::string& name); + /** + * Returns a pointer to the IndexCatalogEntry corresponding to 'desc', where the caller assumes + * shared ownership of the catalog object. Returns null if the entry does not exist. + */ + std::shared_ptr<IndexCatalogEntry> findShared(const IndexDescriptor* desc) const; unsigned size() const { return _entries.size(); @@ -192,20 +197,17 @@ public: /** * Removes from _entries and returns the matching entry or NULL if none matches. */ - IndexCatalogEntry* release(const IndexDescriptor* desc); + std::shared_ptr<IndexCatalogEntry> release(const IndexDescriptor* desc); bool remove(const IndexDescriptor* desc) { - IndexCatalogEntry* entry = release(desc); - delete entry; - return entry; + return static_cast<bool>(release(desc)); } - // pass ownership to EntryContainer - void add(IndexCatalogEntry* entry) { - _entries.push_back(std::unique_ptr<IndexCatalogEntry>{entry}); + void add(std::shared_ptr<IndexCatalogEntry>&& entry) { + _entries.push_back(std::move(entry)); } private: - std::vector<std::unique_ptr<IndexCatalogEntry>> _entries; + std::vector<std::shared_ptr<IndexCatalogEntry>> _entries; }; } // namespace mongo |