STL Memory Versioning
revision.cpp
Go to the documentation of this file.
1 #include "revision.h"
2 #include "versioned.h"
3 #include "segment.h"
4 #include <sstream>
5 
6 thread_local std::shared_ptr<Revision> Revision::currentRevision = std::make_shared<Revision>();
7 
9  std::shared_ptr<Segment> s = std::make_shared<Segment>();
10  root = s;
11  current = s;
12 }
13 
14 Revision::Revision(std::shared_ptr<Segment> my_root, std::shared_ptr<Segment> my_current) {
15  root = my_root;
16  current = my_current;
17 }
18 
19 void PrintRevision(std::shared_ptr<Revision> revision) {
20  if (revision == nullptr) {
21  std::cout << "Revision is null" << std::endl;
22  return;
23  }
24 
25  std::shared_ptr<Segment> s = revision->current;
26 
27  std::ostringstream o;
28  o << std::endl;
29  while (s) {
30  o << "thread: "<< std::this_thread::get_id() << ", segment ver:" << s->version
31  << ", addr: " << s << ", refcount: " << s->refcount << ", written size: " << s->written.size() << std::endl;
32  s = s->parent;
33  }
34 
35  std::cout << o.str() << std::endl;
36 }
static thread_local std::shared_ptr< Revision > currentRevision
The current Revision for current thread.
Definition: revision.h:65
Revision()
Construct for the very first Revision.
Definition: revision.cpp:8
std::shared_ptr< Segment > current
Current Segment of that Revision.
Definition: revision.h:51
std::shared_ptr< Segment > root
Segment from which this Revision was created.
Definition: revision.h:44
void PrintRevision(std::shared_ptr< Revision > revision)
Print revision segments for debugging.
Definition: revision.cpp:19
Implementation of the class Revision.
Implementation of the class Segment.
Implementation of the Versioned classes and interface.