MDBX Containers
Loading...
Searching...
No Matches
TransactionTracker.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _MDBX_CONTAINERS_TRANSACTION_TRACKER_HPP_INCLUDED
3#define _MDBX_CONTAINERS_TRANSACTION_TRACKER_HPP_INCLUDED
4
7
8namespace mdbxc {
9
17 friend class Transaction;
18 protected:
19
22 void bind_txn(MDBX_txn* txn);
23
25 void unbind_txn();
26
29 MDBX_txn* thread_txn() const;
30
31 virtual ~TransactionTracker() = default;
32
33 private:
34 mutable std::mutex m_mutex;
35 std::unordered_map<std::thread::id, MDBX_txn*> m_thread_txns;
36 };
37
38} // namespace mdbxc
39
40#ifdef MDBX_CONTAINERS_HEADER_ONLY
42#endif
43
44#endif // _MDBX_CONTAINERS_TRANSACTION_TRACKER_HPP_INCLUDED
Associates MDBX transactions with threads.
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.
virtual ~TransactionTracker()=default
void unbind_txn()
Unregisters a transaction for a specific thread.