snapshot_impl.cc 787 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #include "rocksdb/snapshot.h"
  6. #include "rocksdb/db.h"
  7. namespace ROCKSDB_NAMESPACE {
  8. ManagedSnapshot::ManagedSnapshot(DB* db) : db_(db),
  9. snapshot_(db->GetSnapshot()) {}
  10. ManagedSnapshot::ManagedSnapshot(DB* db, const Snapshot* _snapshot)
  11. : db_(db), snapshot_(_snapshot) {}
  12. ManagedSnapshot::~ManagedSnapshot() {
  13. if (snapshot_) {
  14. db_->ReleaseSnapshot(snapshot_);
  15. }
  16. }
  17. const Snapshot* ManagedSnapshot::snapshot() { return snapshot_;}
  18. } // namespace ROCKSDB_NAMESPACE