snapshot_impl.cc 748 B

12345678910111213141516171819202122232425
  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/db.h"
  6. #include "rocksdb/snapshot.h"
  7. namespace ROCKSDB_NAMESPACE {
  8. ManagedSnapshot::ManagedSnapshot(DB* db)
  9. : db_(db), 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