summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.h
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-07-31 15:26:11 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-07 13:32:12 +0000
commit9de175fb3776415e7237e6c0af4b76f518adc451 (patch)
tree56a22e0f57be9937d53deed8f76fdbc2502639c3 /src/mongo/db/db_raii.h
parent21d5a8e5bd822e71e5fb8feb2f9e71a7e8cf25f9 (diff)
downloadmongo-9de175fb3776415e7237e6c0af4b76f518adc451.tar.gz
SERVER-47885 Added lookupCollectionByXXXForRead interface to the Collection catalog that returns collection as shared_ptr<const Collection>
AutoGetCollectionForRead and AutoGetCollectionForReadCommand now uses this and holds the shared_ptr. They return the collection as const. Const correct various places to make this possible. Moved some logic from Collection destructors to deregister from the catalog as they may now be destroyed at a later point.
Diffstat (limited to 'src/mongo/db/db_raii.h')
-rw-r--r--src/mongo/db/db_raii.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/mongo/db/db_raii.h b/src/mongo/db/db_raii.h
index d1e9e85cb4e..e8a1157b9ff 100644
--- a/src/mongo/db/db_raii.h
+++ b/src/mongo/db/db_raii.h
@@ -104,14 +104,14 @@ public:
AutoGetCollectionForRead(
OperationContext* opCtx,
const NamespaceStringOrUUID& nsOrUUID,
- AutoGetCollection::ViewMode viewMode = AutoGetCollection::ViewMode::kViewsForbidden,
+ AutoGetCollectionViewMode viewMode = AutoGetCollectionViewMode::kViewsForbidden,
Date_t deadline = Date_t::max());
Database* getDb() const {
return _autoColl->getDb();
}
- Collection* getCollection() const {
+ const Collection* getCollection() const {
return _autoColl->getCollection();
}
@@ -132,7 +132,7 @@ private:
// This field is optional, because the code to wait for majority committed snapshot needs to
// release locks in order to block waiting
- boost::optional<AutoGetCollection> _autoColl;
+ boost::optional<AutoGetCollectionBase<CatalogCollectionLookupForRead>> _autoColl;
};
/**
@@ -147,7 +147,7 @@ public:
AutoGetCollectionForReadCommand(
OperationContext* opCtx,
const NamespaceStringOrUUID& nsOrUUID,
- AutoGetCollection::ViewMode viewMode = AutoGetCollection::ViewMode::kViewsForbidden,
+ AutoGetCollectionViewMode viewMode = AutoGetCollectionViewMode::kViewsForbidden,
Date_t deadline = Date_t::max(),
AutoStatsTracker::LogMode logMode = AutoStatsTracker::LogMode::kUpdateTopAndCurOp);
@@ -155,7 +155,7 @@ public:
return _autoCollForRead.getDb();
}
- Collection* getCollection() const {
+ const Collection* getCollection() const {
return _autoCollForRead.getCollection();
}