memgraph/include/transactions/transaction.hpp

43 lines
826 B
C++
Raw Normal View History

#pragma once
2015-07-31 18:36:41 +08:00
#include <cstdint>
#include <cstdlib>
#include <vector>
#include "mvcc/id.hpp"
#include "storage/locking/record_lock.hpp"
#include "transactions/lock_store.hpp"
#include "transactions/snapshot.hpp"
2015-10-04 15:47:15 +08:00
namespace tx
{
2015-07-31 18:36:41 +08:00
class Engine;
class Transaction
{
friend class Engine;
public:
Transaction(const Id &id, const Snapshot<Id> &snapshot, Engine &engine);
Transaction(const Transaction &) = delete;
Transaction(Transaction &&) = delete;
// index of this transaction
const Id id;
2015-07-07 22:18:26 +08:00
// index of the current command in the current transaction;
uint8_t cid;
// a snapshot of currently active transactions
const Snapshot<Id> snapshot;
void take_lock(RecordLock &lock);
void commit();
void abort();
Engine &engine;
2016-03-12 19:26:56 +08:00
private:
LockStore<RecordLock> locks;
};
2015-10-04 15:47:15 +08:00
}