diff options
Diffstat (limited to 'src/mongo/db/catalog/database_holder.h')
-rw-r--r-- | src/mongo/db/catalog/database_holder.h | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/mongo/db/catalog/database_holder.h b/src/mongo/db/catalog/database_holder.h index 3238b886f01..ce99747937b 100644 --- a/src/mongo/db/catalog/database_holder.h +++ b/src/mongo/db/catalog/database_holder.h @@ -37,62 +37,62 @@ namespace mongo { - class Database; - class OperationContext; +class Database; +class OperationContext; + +/** + * Registry of opened databases. + */ +class DatabaseHolder { +public: + DatabaseHolder() = default; /** - * Registry of opened databases. + * Retrieves an already opened database or returns NULL. Must be called with the database + * locked in at least IS-mode. */ - class DatabaseHolder { - public: - DatabaseHolder() = default; + Database* get(OperationContext* txn, StringData ns) const; - /** - * Retrieves an already opened database or returns NULL. Must be called with the database - * locked in at least IS-mode. - */ - Database* get(OperationContext* txn, StringData ns) const; - - /** - * Retrieves a database reference if it is already opened, or opens it if it hasn't been - * opened/created yet. Must be called with the database locked in X-mode. - * - * @param justCreated Returns whether the database was newly created (true) or it already - * existed (false). Can be NULL if this information is not necessary. - */ - Database* openDb(OperationContext* txn, StringData ns, bool* justCreated = NULL); + /** + * Retrieves a database reference if it is already opened, or opens it if it hasn't been + * opened/created yet. Must be called with the database locked in X-mode. + * + * @param justCreated Returns whether the database was newly created (true) or it already + * existed (false). Can be NULL if this information is not necessary. + */ + Database* openDb(OperationContext* txn, StringData ns, bool* justCreated = NULL); - /** - * Closes the specified database. Must be called with the database locked in X-mode. - */ - void close(OperationContext* txn, StringData ns); + /** + * Closes the specified database. Must be called with the database locked in X-mode. + */ + void close(OperationContext* txn, StringData ns); - /** - * Closes all opened databases. Must be called with the global lock acquired in X-mode. - * - * @param result Populated with the names of the databases, which were closed. - * @param force Force close even if something underway - use at shutdown - */ - bool closeAll(OperationContext* txn, BSONObjBuilder& result, bool force); + /** + * Closes all opened databases. Must be called with the global lock acquired in X-mode. + * + * @param result Populated with the names of the databases, which were closed. + * @param force Force close even if something underway - use at shutdown + */ + bool closeAll(OperationContext* txn, BSONObjBuilder& result, bool force); - /** - * Retrieves the names of all currently opened databases. Does not require locking, but it - * is not guaranteed that the returned set of names will be still valid unless a global - * lock is held, which would prevent database from disappearing or being created. - */ - void getAllShortNames( std::set<std::string>& all ) const { - stdx::lock_guard<SimpleMutex> lk(_m); - for( DBs::const_iterator j=_dbs.begin(); j!=_dbs.end(); ++j ) { - all.insert( j->first ); - } + /** + * Retrieves the names of all currently opened databases. Does not require locking, but it + * is not guaranteed that the returned set of names will be still valid unless a global + * lock is held, which would prevent database from disappearing or being created. + */ + void getAllShortNames(std::set<std::string>& all) const { + stdx::lock_guard<SimpleMutex> lk(_m); + for (DBs::const_iterator j = _dbs.begin(); j != _dbs.end(); ++j) { + all.insert(j->first); } + } - private: - typedef StringMap<Database*> DBs; +private: + typedef StringMap<Database*> DBs; - mutable SimpleMutex _m; - DBs _dbs; - }; + mutable SimpleMutex _m; + DBs _dbs; +}; - DatabaseHolder& dbHolder(); +DatabaseHolder& dbHolder(); } |