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 6 #include "rocksdb/snapshot.h" 7 8 #include "rocksdb/db.h" 9 10 namespace rocksdb { 11 ManagedSnapshot(DB * db)12ManagedSnapshot::ManagedSnapshot(DB* db) : db_(db), 13 snapshot_(db->GetSnapshot()) {} 14 ManagedSnapshot(DB * db,const Snapshot * _snapshot)15ManagedSnapshot::ManagedSnapshot(DB* db, const Snapshot* _snapshot) 16 : db_(db), snapshot_(_snapshot) {} 17 ~ManagedSnapshot()18ManagedSnapshot::~ManagedSnapshot() { 19 if (snapshot_) { 20 db_->ReleaseSnapshot(snapshot_); 21 } 22 } 23 snapshot()24const Snapshot* ManagedSnapshot::snapshot() { return snapshot_;} 25 26 } // namespace rocksdb 27