2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2015-08-07 00:59:05 +00:00
|
|
|
|
|
|
|
#include "rocksdb/db.h"
|
2022-11-02 21:34:24 +00:00
|
|
|
#include "rocksdb/snapshot.h"
|
2015-08-07 00:59:05 +00:00
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2015-08-07 00:59:05 +00:00
|
|
|
|
2022-11-02 21:34:24 +00:00
|
|
|
ManagedSnapshot::ManagedSnapshot(DB* db)
|
|
|
|
: db_(db), snapshot_(db->GetSnapshot()) {}
|
2015-08-07 00:59:05 +00:00
|
|
|
|
2015-12-08 20:25:48 +00:00
|
|
|
ManagedSnapshot::ManagedSnapshot(DB* db, const Snapshot* _snapshot)
|
|
|
|
: db_(db), snapshot_(_snapshot) {}
|
|
|
|
|
2015-08-07 00:59:05 +00:00
|
|
|
ManagedSnapshot::~ManagedSnapshot() {
|
|
|
|
if (snapshot_) {
|
|
|
|
db_->ReleaseSnapshot(snapshot_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-02 21:34:24 +00:00
|
|
|
const Snapshot* ManagedSnapshot::snapshot() { return snapshot_; }
|
2015-08-07 00:59:05 +00:00
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|