2016-08-30 22:12:30 +08:00
|
|
|
|
2015-11-22 02:16:19 +08:00
|
|
|
#pragma once
|
2015-07-04 17:51:33 +08:00
|
|
|
|
2015-07-31 18:36:41 +08:00
|
|
|
#include <cstdint>
|
2016-07-05 11:01:22 +08:00
|
|
|
#include <cstdlib>
|
2015-07-04 17:51:33 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2015-11-22 02:16:19 +08:00
|
|
|
#include "mvcc/id.hpp"
|
2016-01-03 05:20:09 +08:00
|
|
|
#include "storage/locking/record_lock.hpp"
|
2016-07-05 11:01:22 +08:00
|
|
|
#include "transactions/lock_store.hpp"
|
|
|
|
#include "transactions/snapshot.hpp"
|
2016-09-10 03:56:53 +08:00
|
|
|
#include "transactions/transaction_read.hpp"
|
2015-10-08 06:58:29 +08:00
|
|
|
|
2015-10-04 15:47:15 +08:00
|
|
|
namespace tx
|
|
|
|
{
|
2015-07-31 18:36:41 +08:00
|
|
|
|
2016-09-10 03:56:53 +08:00
|
|
|
class Transaction : public TransactionRead
|
2015-07-04 17:51:33 +08:00
|
|
|
{
|
2015-12-06 23:42:47 +08:00
|
|
|
|
|
|
|
public:
|
2016-07-05 11:01:22 +08:00
|
|
|
Transaction(const Id &id, const Snapshot<Id> &snapshot, Engine &engine);
|
|
|
|
Transaction(const Transaction &) = delete;
|
|
|
|
Transaction(Transaction &&) = delete;
|
2015-07-04 17:51:33 +08:00
|
|
|
|
2016-09-10 03:56:53 +08:00
|
|
|
// Returns copy of transaction_read
|
|
|
|
TransactionRead transaction_read();
|
2015-12-06 23:42:47 +08:00
|
|
|
|
2016-08-25 22:29:45 +08:00
|
|
|
// Blocks until all transactions from snapshot finish. After this method,
|
|
|
|
// snapshot will be empty.
|
|
|
|
void wait_for_active();
|
|
|
|
|
2016-07-05 11:01:22 +08:00
|
|
|
void take_lock(RecordLock &lock);
|
2015-12-06 23:42:47 +08:00
|
|
|
void commit();
|
|
|
|
void abort();
|
|
|
|
|
2016-03-12 19:26:56 +08:00
|
|
|
private:
|
2015-12-06 23:42:47 +08:00
|
|
|
LockStore<RecordLock> locks;
|
2015-07-04 17:51:33 +08:00
|
|
|
};
|
2015-10-04 15:47:15 +08:00
|
|
|
}
|