diff options
Diffstat (limited to 'src/mongo/db/range_preserver.h')
-rw-r--r-- | src/mongo/db/range_preserver.h | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/mongo/db/range_preserver.h b/src/mongo/db/range_preserver.h index 818d848914e..5b7b655b66f 100644 --- a/src/mongo/db/range_preserver.h +++ b/src/mongo/db/range_preserver.h @@ -32,40 +32,40 @@ namespace mongo { +/** + * A RangePreserver prevents the RangeDeleter from removing any new data ranges in a collection. + * Previously queued ranges may still be deleted but the documents in those ranges will be + * filtered by CollectionMetadata::belongsToMe. + * + * TODO(greg/hk): Currently, creating a ClientCursor is how we accomplish this. This should + * change. + */ +class RangePreserver { +public: /** - * A RangePreserver prevents the RangeDeleter from removing any new data ranges in a collection. - * Previously queued ranges may still be deleted but the documents in those ranges will be - * filtered by CollectionMetadata::belongsToMe. - * - * TODO(greg/hk): Currently, creating a ClientCursor is how we accomplish this. This should - * change. + * Sharding uses the set of active cursor IDs as the current state. We add a dummy + * ClientCursor, which creates an additional cursor ID. The cursor ID lasts as long as this + * object does. The ClientCursorPin guarantees that the underlying ClientCursor is not + * deleted until this object goes out of scope. */ - class RangePreserver { - public: - /** - * Sharding uses the set of active cursor IDs as the current state. We add a dummy - * ClientCursor, which creates an additional cursor ID. The cursor ID lasts as long as this - * object does. The ClientCursorPin guarantees that the underlying ClientCursor is not - * deleted until this object goes out of scope. - */ - RangePreserver(const Collection* collection) { - // Empty collections don't have any data we need to preserve - if (collection) { - // Not a memory leak. Cached in a static structure by CC's ctor. - ClientCursor* cc = new ClientCursor(collection); + RangePreserver(const Collection* collection) { + // Empty collections don't have any data we need to preserve + if (collection) { + // Not a memory leak. Cached in a static structure by CC's ctor. + ClientCursor* cc = new ClientCursor(collection); - // Pin keeps the CC from being deleted while it's in scope. We delete it ourselves. - _pin.reset(new ClientCursorPin(collection->getCursorManager(), cc->cursorid())); - } + // Pin keeps the CC from being deleted while it's in scope. We delete it ourselves. + _pin.reset(new ClientCursorPin(collection->getCursorManager(), cc->cursorid())); } + } - ~RangePreserver() { - if (_pin) - _pin->deleteUnderlying(); - } + ~RangePreserver() { + if (_pin) + _pin->deleteUnderlying(); + } - private: - std::unique_ptr<ClientCursorPin> _pin; - }; +private: + std::unique_ptr<ClientCursorPin> _pin; +}; } // namespace mongo |