2017-06-12 16:21:19 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "mvcc/record.hpp"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief - Empty class which inherits from mvcc:Record.
|
|
|
|
*/
|
2017-09-27 20:45:50 +08:00
|
|
|
class Prop : public mvcc::Record<Prop> {
|
|
|
|
public:
|
|
|
|
Prop *CloneData() { return new Prop; }
|
|
|
|
};
|
2017-06-12 16:21:19 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief - Class which inherits from mvcc::Record and takes an atomic variable
|
|
|
|
* to count number of destructor calls (to test if the record is actually
|
|
|
|
* deleted).
|
|
|
|
*/
|
|
|
|
class DestrCountRec : public mvcc::Record<DestrCountRec> {
|
|
|
|
public:
|
|
|
|
DestrCountRec(std::atomic<int> &count) : count_(count) {}
|
2017-09-27 20:45:50 +08:00
|
|
|
DestrCountRec *CloneData() { return new DestrCountRec(count_); }
|
2017-06-12 16:21:19 +08:00
|
|
|
~DestrCountRec() { ++count_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::atomic<int> &count_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// helper function for creating a GC snapshot
|
|
|
|
// if given a nullptr it makes a GC snapshot like there
|
|
|
|
// are no active transactions
|
|
|
|
auto GcSnapshot(tx::Engine &engine, tx::Transaction *t) {
|
|
|
|
if (t != nullptr) {
|
|
|
|
tx::Snapshot gc_snap = t->snapshot();
|
|
|
|
gc_snap.insert(t->id_);
|
|
|
|
return gc_snap;
|
|
|
|
} else {
|
2017-11-24 21:46:42 +08:00
|
|
|
return engine.GcSnapshot();
|
2017-06-12 16:21:19 +08:00
|
|
|
}
|
|
|
|
}
|