memgraph/tests/unit/mvcc_gc_common.hpp
Matej Ferencevic 4e5fe37dd6 Remove virtual and pimpl from single node
Summary:
This diff removes: `SingleNodeRecoveryTransactions`, `TypemapPack`
It also removes virtual and/or pimpl from: `SingleNodeCounters`,
`StorageGcSingleNode`, `SingleNodeConcurrentIdMapper`,
accessors (revert D1510), transaction engine, `GraphDbAccessor`, `GraphDb`

Reviewers: msantl, teon.banek

Reviewed By: msantl, teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1639
2018-10-09 11:48:30 +02:00

41 lines
1.0 KiB
C++

#pragma once
#include "mvcc/single_node/record.hpp"
#include "transactions/single_node/engine.hpp"
/**
* @brief - Empty class which inherits from mvcc:Record.
*/
class Prop : public mvcc::Record<Prop> {
public:
Prop *CloneData() { return new Prop; }
};
/**
* @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:
explicit DestrCountRec(std::atomic<int> &count) : count_(count) {}
DestrCountRec *CloneData() { return new DestrCountRec(count_); }
~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 {
return engine.GlobalGcSnapshot();
}
}