56 lines
1.2 KiB
C
Raw Normal View History

2013-11-19 10:24:31 +00:00
#ifndef ERA_DETAIL_H
#define ERA_DETAIL_H
#include "base/endian_utils.h"
2014-01-14 23:59:12 +00:00
#include "persistent-data/transaction_manager.h"
2013-11-19 10:24:31 +00:00
//----------------------------------------------------------------
namespace era {
struct era_detail_disk {
base::le32 nr_bits;
base::le64 writeset_root;
} __attribute__ ((packed));
2013-11-19 10:24:31 +00:00
struct era_detail {
era_detail()
: nr_bits(0),
writeset_root(0) {
}
2013-11-19 10:24:31 +00:00
uint32_t nr_bits;
uint64_t writeset_root;
2013-11-19 10:24:31 +00:00
};
2014-01-14 23:59:12 +00:00
struct era_detail_ref_counter {
2014-08-07 15:43:01 +01:00
era_detail_ref_counter(persistent_data::transaction_manager::ptr tm)
: tm_(tm) {
2014-01-23 00:46:03 +00:00
}
2014-01-14 23:59:12 +00:00
2014-08-07 15:43:01 +01:00
void inc(era_detail const &d) {
tm_->get_sm()->inc(d.writeset_root);
2014-01-23 00:46:03 +00:00
}
void dec(persistent_data::block_address b) {
2014-08-07 15:43:01 +01:00
// I don't think we ever do this in the tools
throw std::runtime_error("not implemented");
2014-01-23 00:46:03 +00:00
}
2014-08-07 15:43:01 +01:00
private:
persistent_data::transaction_manager::ptr tm_;
2014-01-14 23:59:12 +00:00
};
2013-11-19 10:24:31 +00:00
struct era_detail_traits {
typedef era_detail_disk disk_type;
typedef era_detail value_type;
2014-01-14 23:59:12 +00:00
typedef era_detail_ref_counter ref_counter;
2013-11-19 10:24:31 +00:00
static void unpack(disk_type const &disk, value_type &value);
static void pack(value_type const &value, disk_type &disk);
};
}
//----------------------------------------------------------------
#endif