forked from blue/lmdbal
RAII transactions
This commit is contained in:
parent
a9aa6b549f
commit
de741eda21
22 changed files with 689 additions and 222 deletions
46
src/transaction.h
Normal file
46
src/transaction.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
|
||||
#include "base.h"
|
||||
|
||||
namespace LMDBAL {
|
||||
class iStorage;
|
||||
|
||||
class Transaction {
|
||||
friend class Base;
|
||||
friend class iStorage;
|
||||
public:
|
||||
explicit Transaction();
|
||||
explicit Transaction(Transaction&& other);
|
||||
Transaction(const Transaction& other) = delete;
|
||||
Transaction& operator = (const Transaction& other) = delete;
|
||||
Transaction& operator = (Transaction&& other);
|
||||
virtual ~Transaction();
|
||||
|
||||
void terminate();
|
||||
bool isActive() const;
|
||||
|
||||
protected:
|
||||
Transaction(TransactionID txn, const Base* parent);
|
||||
|
||||
protected:
|
||||
TransactionID txn;
|
||||
bool active;
|
||||
const Base* parent;
|
||||
};
|
||||
|
||||
class WriteTransaction : public Transaction {
|
||||
friend class Base;
|
||||
public:
|
||||
explicit WriteTransaction();
|
||||
explicit WriteTransaction(WriteTransaction&& other);
|
||||
WriteTransaction(const WriteTransaction& other) = delete;
|
||||
WriteTransaction& operator = (const WriteTransaction& other) = delete;
|
||||
|
||||
void commit();
|
||||
void abort();
|
||||
|
||||
protected:
|
||||
WriteTransaction(TransactionID txn, Base* parent);
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue