diff options
Diffstat (limited to 'src/mongo/db/storage/snapshot.h')
-rw-r--r-- | src/mongo/db/storage/snapshot.h | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/src/mongo/db/storage/snapshot.h b/src/mongo/db/storage/snapshot.h index 5d432ba3cbc..6ce5b57e51d 100644 --- a/src/mongo/db/storage/snapshot.h +++ b/src/mongo/db/storage/snapshot.h @@ -34,56 +34,60 @@ namespace mongo { - class SnapshotId { - static const uint64_t kNullId = 0; - public: - SnapshotId() - : _id(kNullId) { - } - - // 0 is NULL - explicit SnapshotId(uint64_t id) - : _id(id) { - invariant(id != kNullId); - } - - bool isNull() const { return _id == kNullId; } - - bool operator==(const SnapshotId& other) const { - return _id == other._id; - } - - bool operator!=(const SnapshotId& other) const { - return _id != other._id; - } - - private: - uint64_t _id; - }; - - template<typename T> - class Snapshotted { - public: - Snapshotted() - : _id(), _value() { - } - - Snapshotted(SnapshotId id, const T& value ) : - _id(id), _value(value) { - } - - void reset() { - *this = Snapshotted(); - } - - void setValue(const T& t) { _value = t; } - - SnapshotId snapshotId() const { return _id; } - const T& value() const { return _value; } - T& value() { return _value; } - - private: - SnapshotId _id; - T _value; - }; +class SnapshotId { + static const uint64_t kNullId = 0; + +public: + SnapshotId() : _id(kNullId) {} + + // 0 is NULL + explicit SnapshotId(uint64_t id) : _id(id) { + invariant(id != kNullId); + } + + bool isNull() const { + return _id == kNullId; + } + + bool operator==(const SnapshotId& other) const { + return _id == other._id; + } + + bool operator!=(const SnapshotId& other) const { + return _id != other._id; + } + +private: + uint64_t _id; +}; + +template <typename T> +class Snapshotted { +public: + Snapshotted() : _id(), _value() {} + + Snapshotted(SnapshotId id, const T& value) : _id(id), _value(value) {} + + void reset() { + *this = Snapshotted(); + } + + void setValue(const T& t) { + _value = t; + } + + SnapshotId snapshotId() const { + return _id; + } + const T& value() const { + return _value; + } + T& value() { + return _value; + } + +private: + SnapshotId _id; + T _value; +}; } |