diff options
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r-- | src/mongo/db/catalog/cursor_manager.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/catalog/cursor_manager.h | 16 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/mongo/db/catalog/cursor_manager.cpp b/src/mongo/db/catalog/cursor_manager.cpp index e097bd1aee7..ea03c3175e1 100644 --- a/src/mongo/db/catalog/cursor_manager.cpp +++ b/src/mongo/db/catalog/cursor_manager.cpp @@ -285,8 +285,8 @@ namespace mongo { } std::size_t CursorManager::timeoutCursorsGlobal(OperationContext* txn, - int millisSinceLastCall) {; - return globalCursorIdCache->timeoutCursors(txn, millisSinceLastCall); + int millisSinceLastCall) { + return globalCursorIdCache->timeoutCursors(txn, millisSinceLastCall); } int CursorManager::eraseCursorGlobalIfAuthorized(OperationContext* txn, int n, @@ -477,11 +477,11 @@ namespace mongo { cursor->unsetPinned(); } - bool CursorManager::ownsCursorId( CursorId cursorId ) { + bool CursorManager::ownsCursorId( CursorId cursorId ) const { return _collectionCacheRuntimeId == idFromCursorId( cursorId ); } - void CursorManager::getCursorIds( std::set<CursorId>* openCursors ) { + void CursorManager::getCursorIds( std::set<CursorId>* openCursors ) const { SimpleMutex::scoped_lock lk( _mutex ); for ( CursorMap::const_iterator i = _cursors.begin(); i != _cursors.end(); ++i ) { @@ -490,7 +490,7 @@ namespace mongo { } } - size_t CursorManager::numCursors(){ + size_t CursorManager::numCursors() const { SimpleMutex::scoped_lock lk( _mutex ); return _cursors.size(); } diff --git a/src/mongo/db/catalog/cursor_manager.h b/src/mongo/db/catalog/cursor_manager.h index 5c5619c5ebb..78430d72e57 100644 --- a/src/mongo/db/catalog/cursor_manager.h +++ b/src/mongo/db/catalog/cursor_manager.h @@ -99,9 +99,17 @@ namespace mongo { bool eraseCursor(OperationContext* txn, CursorId id, bool checkAuth ); - bool ownsCursorId( CursorId cursorId ); - void getCursorIds( std::set<CursorId>* openCursors ); - std::size_t numCursors(); + /** + * Returns true if the space of cursor ids that cursor manager is responsible for includes + * the given cursor id. Otherwise, returns false. + * + * The return value of this method does not indicate any information about whether or not a + * cursor actually exists with the given cursor id. Use the find() method for that purpose. + */ + bool ownsCursorId( CursorId cursorId ) const; + + void getCursorIds( std::set<CursorId>* openCursors ) const; + std::size_t numCursors() const; /** * @param pin - if true, will try to pin cursor @@ -135,7 +143,7 @@ namespace mongo { unsigned _collectionCacheRuntimeId; boost::scoped_ptr<PseudoRandom> _random; - SimpleMutex _mutex; + mutable SimpleMutex _mutex; typedef unordered_set<PlanExecutor*> ExecSet; ExecSet _nonCachedExecutors; |