MDBX Containers
Loading...
Searching...
No Matches
TransactionTracker.ipp
Go to the documentation of this file.
1namespace mdbxc {
2
3 inline void TransactionTracker::bind_txn(MDBX_txn* txn) {
4 std::lock_guard<std::mutex> lock(m_mutex);
5 m_thread_txns[std::this_thread::get_id()] = txn;
6 }
7
9 std::lock_guard<std::mutex> lock(m_mutex);
10 m_thread_txns.erase(std::this_thread::get_id());
11 }
12
13 inline MDBX_txn* TransactionTracker::thread_txn() const {
14 std::lock_guard<std::mutex> lock(m_mutex);
15 auto it = m_thread_txns.find(std::this_thread::get_id());
16 return (it != m_thread_txns.end()) ? it->second : nullptr;
17 }
18
19} // namespace mdbxc
MDBX_txn * thread_txn() const
Retrieves the transaction associated with the current thread.
void bind_txn(MDBX_txn *txn)
Registers a transaction for a specific thread.
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.
void unbind_txn()
Unregisters a transaction for a specific thread.