MDBX Containers
Loading...
Searching...
No Matches
Transaction.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _MDBX_CONTAINERS_TRANSACTION_HPP_INCLUDED
3#define _MDBX_CONTAINERS_TRANSACTION_HPP_INCLUDED
4
7
8namespace mdbxc {
9
18
26 friend class Connection;
27 public:
28
33 virtual ~Transaction();
34
41 void begin();
42
49 void commit();
50
57 void rollback();
58
61 MDBX_txn *handle() const noexcept;
62
69 MDBX_env* env,
70 TransactionMode mode);
71
72 Transaction(Transaction&&) noexcept = default;
73 Transaction& operator=(Transaction&&) noexcept = default;
74
75 private:
76
77 Transaction(const Transaction&) = delete;
78 Transaction& operator=(const Transaction&) = delete;
79
81 MDBX_env* m_env = nullptr;
82 MDBX_txn* m_txn = nullptr;
84 bool m_started = false;
85 }; // Transaction
86
87}; // namespace mdbxc
88
89#ifdef MDBX_CONTAINERS_HEADER_ONLY
90#include "Transaction.ipp"
91#endif
92
93#endif // _MDBX_CONTAINERS_TRANSACTION_HPP_INCLUDED
Associates MDBX transactions with threads.
TransactionMode m_mode
Current transaction mode.
MDBX_env * m_env
Pointer to the MDBX environment handle.
Transaction(TransactionTracker *registry, MDBX_env *env, TransactionMode mode)
Constructs a new transaction object.
friend class Connection
virtual ~Transaction()
Destructor that safely closes or resets the transaction.
void begin()
Starts the transaction.
TransactionTracker * m_registry
void rollback()
Rolls back the transaction.
void commit()
Commits the transaction.
MDBX_txn * m_txn
MDBX transaction handle.
MDBX_txn * handle() const noexcept
Returns the internal MDBX transaction handle.
TransactionMode
Specifies the access mode of a transaction.
@ READ_ONLY
Read-only transaction (no write operations allowed).
@ WRITABLE
Writable transaction (allows inserts, updates, deletes).