rogue
Loading...
Searching...
No Matches
TransactionLock.h
Go to the documentation of this file.
1
17#ifndef __ROGUE_INTERFACES_MEMORY_TRANSACTION_LOCK_H__
18#define __ROGUE_INTERFACES_MEMORY_TRANSACTION_LOCK_H__
19#include "rogue/Directives.h"
20
21#include <stdint.h>
22
23#include <memory>
24#include <thread>
25
26namespace rogue {
27namespace interfaces {
28namespace memory {
29
30class Transaction;
31
41 std::shared_ptr<rogue::interfaces::memory::Transaction> tran_;
42 bool locked_;
43
44 public:
58 static std::shared_ptr<rogue::interfaces::memory::TransactionLock> create(
59 std::shared_ptr<rogue::interfaces::memory::Transaction> transaction);
60
70 explicit TransactionLock(std::shared_ptr<rogue::interfaces::memory::Transaction> transaction);
71
75 static void setup_python();
76
81
87 void lock();
88
94 void unlock();
95
102 void enter();
103
110 void exit(void*, void*, void*);
111};
112
116typedef std::shared_ptr<rogue::interfaces::memory::TransactionLock> TransactionLockPtr;
117
118} // namespace memory
119} // namespace interfaces
120} // namespace rogue
121
122#endif
Scoped lock wrapper for a memory transaction.
static std::shared_ptr< rogue::interfaces::memory::TransactionLock > create(std::shared_ptr< rogue::interfaces::memory::Transaction > transaction)
Creates a transaction lock wrapper.
void unlock()
Unlocks the associated transaction when currently locked.
void lock()
Locks the associated transaction when not already locked.
void enter()
Python context-manager entry hook.
~TransactionLock()
Destroys the wrapper and releases any held lock.
static void setup_python()
Registers this type with Python bindings.
void exit(void *, void *, void *)
Python context-manager exit hook.
std::shared_ptr< rogue::interfaces::memory::TransactionLock > TransactionLockPtr
Shared pointer alias for TransactionLock.