diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-05-15 15:20:11 -0400 |
---|---|---|
committer | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-05-15 15:35:38 -0400 |
commit | 9af1defd2b1b831322e716baa8a4e54b27bd534a (patch) | |
tree | eaded148b88afb2d843dc821308621f7abf9ddc3 /src/mongo/db/catalog/collection_catalog.h | |
parent | 6fdacbfe6dce35b538b5ee00305fae4b9cd07fb2 (diff) | |
download | mongo-9af1defd2b1b831322e716baa8a4e54b27bd534a.tar.gz |
SERVER-37988 Add an optional predicate argument in forEachCollectionFromDb() to allow skipping unsatisfied collections without grabbing them in the desired lock mode
Diffstat (limited to 'src/mongo/db/catalog/collection_catalog.h')
-rw-r--r-- | src/mongo/db/catalog/collection_catalog.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/collection_catalog.h b/src/mongo/db/catalog/collection_catalog.h index 8a7dcaae650..475d12241fe 100644 --- a/src/mongo/db/catalog/collection_catalog.h +++ b/src/mongo/db/catalog/collection_catalog.h @@ -56,6 +56,9 @@ class CollectionCatalog { struct CollectionInfo; public: + using CollectionInfoFn = std::function<bool(const Collection* collection, + const CollectionCatalogEntry* catalogEntry)>; + class iterator { public: using value_type = Collection*; @@ -217,6 +220,12 @@ public: boost::optional<CollectionUUID> lookupUUIDByNSS(const NamespaceString& nss) const; /** + * Returns whether the collection with 'uuid' satisfies the provided 'predicate'. If the + * collection with 'uuid' is not found, false is returned. + */ + bool checkIfCollectionSatisfiable(CollectionUUID uuid, CollectionInfoFn predicate) const; + + /** * This function gets the UUIDs of all collections from `dbName`. * * If the caller does not take a strong database lock, some of UUIDs might no longer exist (due @@ -284,6 +293,10 @@ private: class FinishDropChange; friend class CollectionCatalog::iterator; + Collection* _lookupCollectionByUUID(WithLock, CollectionUUID uuid) const; + CollectionCatalogEntry* _lookupCollectionCatalogEntryByUUID(WithLock, + CollectionUUID uuid) const; + const std::vector<CollectionUUID>& _getOrdering_inlock(const StringData& db, const stdx::lock_guard<stdx::mutex>&); mutable mongo::stdx::mutex _catalogLock; |