memgraph/include/transactions/transaction.hpp

40 lines
839 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"
#include "transactions/transaction_read.hpp"
2015-10-04 15:47:15 +08:00
namespace tx
{
2015-07-31 18:36:41 +08:00
class Transaction : public TransactionRead
{
public:
Transaction(const Id &id, const Snapshot<Id> &snapshot, Engine &engine);
Transaction(const Transaction &) = delete;
Transaction(Transaction &&) = delete;
// Returns copy of transaction_read
TransactionRead transaction_read();
// Blocks until all transactions from snapshot finish. After this method,
// snapshot will be empty.
void wait_for_active();
void take_lock(RecordLock &lock);
void commit();
void abort();
2016-03-12 19:26:56 +08:00
private:
LockStore<RecordLock> locks;
};
2015-10-04 15:47:15 +08:00
}