MDBX Containers
Loading...
Searching...
No Matches
mdbxc::TransactionTracker Class Reference

Associates MDBX transactions with threads. More...

#include <TransactionTracker.hpp>

Inheritance diagram for mdbxc::TransactionTracker:
mdbxc::Connection

Protected Member Functions

void bind_txn (MDBX_txn *txn)
 Registers a transaction for a specific thread.
 
void unbind_txn ()
 Unregisters a transaction for a specific thread.
 
MDBX_txn * thread_txn () const
 Retrieves the transaction associated with the current thread.
 
virtual ~TransactionTracker ()=default
 

Private Attributes

std::mutex m_mutex
 Protects access to m_thread_txns.
 
std::unordered_map< std::thread::id, MDBX_txn * > m_thread_txns
 Map of thread IDs to transaction pointers.
 

Friends

class Transaction
 

Detailed Description

Associates MDBX transactions with threads.

Manages a map from thread IDs to MDBX transaction pointers, allowing reuse and cleanup of transactions for specific threads.

Definition at line 16 of file TransactionTracker.hpp.

Constructor & Destructor Documentation

◆ ~TransactionTracker()

virtual mdbxc::TransactionTracker::~TransactionTracker ( )
protectedvirtualdefault

Member Function Documentation

◆ bind_txn()

void mdbxc::TransactionTracker::bind_txn ( MDBX_txn * txn)
inlineprotected

Registers a transaction for a specific thread.

Parameters
txnPointer to the MDBX transaction.

Definition at line 3 of file TransactionTracker.ipp.

◆ thread_txn()

MDBX_txn * mdbxc::TransactionTracker::thread_txn ( ) const
inlineprotected

Retrieves the transaction associated with the current thread.

Returns
Pointer to the MDBX transaction, or nullptr if not found.

Definition at line 13 of file TransactionTracker.ipp.

◆ unbind_txn()

void mdbxc::TransactionTracker::unbind_txn ( )
inlineprotected

Unregisters a transaction for a specific thread.

Definition at line 8 of file TransactionTracker.ipp.

Friends And Related Symbol Documentation

◆ Transaction

friend class Transaction
friend

Definition at line 17 of file TransactionTracker.hpp.

Member Data Documentation

◆ m_mutex

std::mutex mdbxc::TransactionTracker::m_mutex
mutableprivate

Protects access to m_thread_txns.

Definition at line 34 of file TransactionTracker.hpp.

◆ m_thread_txns

std::unordered_map<std::thread::id, MDBX_txn*> mdbxc::TransactionTracker::m_thread_txns
private

Map of thread IDs to transaction pointers.

Definition at line 35 of file TransactionTracker.hpp.


The documentation for this class was generated from the following files: