2016-09-08 20:25:52 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "mvcc/id.hpp"
|
|
|
|
#include "transactions/snapshot.hpp"
|
|
|
|
|
|
|
|
namespace tx
|
|
|
|
{
|
|
|
|
|
|
|
|
class Engine;
|
|
|
|
|
2016-09-10 03:56:53 +08:00
|
|
|
// Has read only capbilities.
|
|
|
|
// TODO: Not all applicable methods in code have been changed to accept
|
|
|
|
// TransactionRead instead of a Transaction.
|
|
|
|
class TransactionRead
|
2016-09-08 20:25:52 +08:00
|
|
|
{
|
|
|
|
friend class Engine;
|
|
|
|
|
|
|
|
public:
|
2016-09-10 03:56:53 +08:00
|
|
|
TransactionRead(Engine &engine);
|
2016-09-08 20:25:52 +08:00
|
|
|
|
2016-09-10 03:56:53 +08:00
|
|
|
TransactionRead(const Id &&id, const Snapshot<Id> &&snapshot,
|
|
|
|
Engine &engine);
|
2016-09-08 20:25:52 +08:00
|
|
|
|
2016-09-10 03:56:53 +08:00
|
|
|
TransactionRead(const Id &id, const Snapshot<Id> &snapshot, Engine &engine);
|
2016-09-08 20:25:52 +08:00
|
|
|
|
2016-09-13 03:13:04 +08:00
|
|
|
// True if this transaction and every transaction from snapshot have
|
|
|
|
// finished.
|
|
|
|
bool all_finished();
|
|
|
|
|
2016-09-08 20:25:52 +08:00
|
|
|
// Return id of oldest transaction from snapshot.
|
|
|
|
Id oldest_active();
|
|
|
|
|
|
|
|
// True if id is in snapshot.
|
|
|
|
bool in_snapshot(const Id &id) const;
|
|
|
|
|
|
|
|
// index of this transaction
|
|
|
|
const Id id;
|
|
|
|
|
|
|
|
// index of the current command in the current transaction;
|
|
|
|
uint8_t cid;
|
|
|
|
|
|
|
|
Engine &engine;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// a snapshot of currently active transactions
|
|
|
|
Snapshot<Id> snapshot;
|
|
|
|
};
|
|
|
|
}
|