]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
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). | |
7c673cae FG |
5 | |
6 | #pragma once | |
7 | #ifndef ROCKSDB_LITE | |
8 | ||
9 | #include "rocksdb/db.h" | |
10 | #include "rocksdb/options.h" | |
11 | #include "rocksdb/utilities/optimistic_transaction_db.h" | |
12 | ||
13 | namespace rocksdb { | |
14 | ||
15 | class OptimisticTransactionDBImpl : public OptimisticTransactionDB { | |
16 | public: | |
11fdf7f2 TL |
17 | explicit OptimisticTransactionDBImpl(DB* db, bool take_ownership = true) |
18 | : OptimisticTransactionDB(db), db_owner_(take_ownership) {} | |
7c673cae | 19 | |
11fdf7f2 TL |
20 | ~OptimisticTransactionDBImpl() { |
21 | // Prevent this stackable from destroying | |
22 | // base db | |
23 | if (!db_owner_) { | |
24 | db_ = nullptr; | |
25 | } | |
26 | } | |
7c673cae FG |
27 | |
28 | Transaction* BeginTransaction(const WriteOptions& write_options, | |
29 | const OptimisticTransactionOptions& txn_options, | |
30 | Transaction* old_txn) override; | |
31 | ||
7c673cae | 32 | private: |
11fdf7f2 TL |
33 | |
34 | bool db_owner_; | |
7c673cae FG |
35 | |
36 | void ReinitializeTransaction(Transaction* txn, | |
37 | const WriteOptions& write_options, | |
38 | const OptimisticTransactionOptions& txn_options = | |
39 | OptimisticTransactionOptions()); | |
40 | }; | |
41 | ||
42 | } // namespace rocksdb | |
43 | #endif // ROCKSDB_LITE |