Storage Engine API
mongo::SavedCursorRegistry Class Reference

Class that stores active cursors that have been saved (as part of yielding) to allow them to be invalidated if the thing they pointed at goes away. More...

#include <record_store_v1_base.h>

Detailed Description

Class that stores active cursors that have been saved (as part of yielding) to allow them to be invalidated if the thing they pointed at goes away.

The registry is thread-safe, as readers may concurrently register and remove their cursors. Contention is expected to be very low, as yielding is infrequent. This logically belongs to the RecordStore, but is not contained in it to facilitate unit testing.

Classes

struct  SavedCursor
 The destructor ensures the cursor is unregistered when an exception is thrown. More...
 

Public Member Functions

 ~SavedCursorRegistry ()
 
void registerCursor (SavedCursor *cursor)
 Adds given saved cursor to SavedCursorRegistry. More...
 
bool unregisterCursor (SavedCursor *cursor)
 Removes given saved cursor. More...
 
void invalidateCursorsForBucket (DiskLoc bucket)
 When a btree-bucket disappears due to merge/split or similar, this invalidates all cursors that point at the same bucket by removing them from the registry. More...
 

Private Types

typedef stdx::unordered_set< SavedCursor * > SavedCursorSet
 

Private Attributes

SpinLock _mutex
 
SavedCursorSet _cursors
 

Member Typedef Documentation

◆ SavedCursorSet

typedef stdx::unordered_set<SavedCursor*> mongo::SavedCursorRegistry::SavedCursorSet
private

Constructor & Destructor Documentation

◆ ~SavedCursorRegistry()

mongo::SavedCursorRegistry::~SavedCursorRegistry ( )

Member Function Documentation

◆ invalidateCursorsForBucket()

void mongo::SavedCursorRegistry::invalidateCursorsForBucket ( DiskLoc  bucket)

When a btree-bucket disappears due to merge/split or similar, this invalidates all cursors that point at the same bucket by removing them from the registry.

◆ registerCursor()

void mongo::SavedCursorRegistry::registerCursor ( SavedCursor cursor)

Adds given saved cursor to SavedCursorRegistry.

Doesn't take ownership.

◆ unregisterCursor()

bool mongo::SavedCursorRegistry::unregisterCursor ( SavedCursor cursor)

Removes given saved cursor.

Returns true if the cursor was still present, and false if it had already been removed due to invalidation. Doesn't take ownership.

Member Data Documentation

◆ _cursors

SavedCursorSet mongo::SavedCursorRegistry::_cursors
private

◆ _mutex

SpinLock mongo::SavedCursorRegistry::_mutex
private

The documentation for this class was generated from the following files: