![]() |
MDBX Containers
|
Manages MDBX transactions with automatic cleanup and error handling. More...
#include <Transaction.hpp>
Public Member Functions | |
virtual | ~Transaction () |
Destructor that safely closes or resets the transaction. | |
void | begin () |
Starts the transaction. | |
void | commit () |
Commits the transaction. | |
void | rollback () |
Rolls back the transaction. | |
MDBX_txn * | handle () const noexcept |
Returns the internal MDBX transaction handle. | |
Transaction (TransactionTracker *registry, MDBX_env *env, TransactionMode mode) | |
Constructs a new transaction object. | |
Transaction (Transaction &&) noexcept=default | |
Transaction & | operator= (Transaction &&) noexcept=default |
Private Member Functions | |
Transaction (const Transaction &)=delete | |
Transaction & | operator= (const Transaction &)=delete |
Private Attributes | |
TransactionTracker * | m_registry = nullptr |
MDBX_env * | m_env = nullptr |
Pointer to the MDBX environment handle. | |
MDBX_txn * | m_txn = nullptr |
MDBX transaction handle. | |
TransactionMode | m_mode |
Current transaction mode. | |
bool | m_started = false |
Friends | |
class | Connection |
Manages MDBX transactions with automatic cleanup and error handling.
Supports both read-only and writable modes. Provides methods for beginning, committing, and rolling back transactions, with integration of MDBX-specific behavior.
Definition at line 25 of file Transaction.hpp.
|
inlinevirtual |
Destructor that safely closes or resets the transaction.
If the transaction is still active, read-only transactions are reset (reusable), and writable transactions are aborted.
Definition at line 8 of file Transaction.ipp.
|
inline |
Constructs a new transaction object.
registry | Transaction tracker used to associate the transaction with the current thread. |
env | Pointer to the MDBX environment handle. |
mode | Access mode of the transaction. |
Definition at line 3 of file Transaction.ipp.
|
defaultnoexcept |
|
privatedelete |
|
inline |
Starts the transaction.
For read-only transactions, uses a shared reusable handle and attempts renewal. For writable transactions, begins a new transaction using the MDBX environment.
MdbxException | if the transaction is already started or if beginning fails. |
Definition at line 15 of file Transaction.ipp.
|
inline |
Commits the transaction.
For read-only transactions, resets the handle for reuse. For writable transactions, commits the changes and closes the handle.
MdbxException | if no transaction is active or commit/reset fails. |
Definition at line 27 of file Transaction.ipp.
|
inlinenoexcept |
Returns the internal MDBX transaction handle.
Definition at line 77 of file Transaction.ipp.
|
privatedelete |
|
defaultnoexcept |
|
inline |
Rolls back the transaction.
For read-only transactions, resets the handle. For writable transactions, aborts the transaction.
MdbxException | if no transaction is active or rollback/reset fails. |
Definition at line 52 of file Transaction.ipp.
|
friend |
Definition at line 26 of file Transaction.hpp.
|
private |
Pointer to the MDBX environment handle.
Definition at line 81 of file Transaction.hpp.
|
private |
Current transaction mode.
Definition at line 83 of file Transaction.hpp.
|
private |
Definition at line 80 of file Transaction.hpp.
|
private |
Definition at line 84 of file Transaction.hpp.
|
private |
MDBX transaction handle.
Definition at line 82 of file Transaction.hpp.