Add GetSharedSnapshot() to Transaction

This commit is contained in:
Yanqin Jin 2022-04-15 18:24:40 -07:00
parent 45b2bc6124
commit 14a7f26642
2 changed files with 8 additions and 0 deletions

View File

@ -193,6 +193,10 @@ class Transaction {
// is called, or the Transaction is deleted.
virtual const Snapshot* GetSnapshot() const = 0;
// Returns the Snapshot created by the last call to SetSnapshot().
// The returned snapshot can outlive the transaction.
virtual std::shared_ptr<const Snapshot> GetSharedSnapshot() const = 0;
// Clears the current snapshot (i.e. no snapshot will be 'set')
//
// This removes any snapshot that currently exists or is set to be created

View File

@ -206,6 +206,10 @@ class TransactionBaseImpl : public Transaction {
return snapshot_.get();
}
std::shared_ptr<const Snapshot> GetSharedSnapshot() const override {
return snapshot_;
}
virtual void SetSnapshot() override;
void SetSnapshotOnNextOperation(
std::shared_ptr<TransactionNotifier> notifier = nullptr) override;