STL Memory Versioning
Public Member Functions | List of all members
vs::thread Class Reference

std::thread wrapper with additional logic for managing Revisions More...

#include <vs_thread.h>

Inheritance diagram for vs::thread:
Inheritance graph
[legend]
Collaboration diagram for vs::thread:
Collaboration graph
[legend]

Public Member Functions

template<typename Function , typename... Args>
 thread (Function &&f, Args &&... args)
 Construcs thread and creates new Revision for it. More...
 
void join ()
 Joins thread and it's Revision. More...
 

Detailed Description

std::thread wrapper with additional logic for managing Revisions

Definition at line 13 of file vs_thread.h.

Constructor & Destructor Documentation

◆ thread()

template<typename Function , typename... Args>
vs::thread::thread ( Function &&  f,
Args &&...  args 
)
inlineexplicit

Construcs thread and creates new Revision for it.

Template Parameters
Function- callable
Args- optional arguments for function
Parameters
f- function to call
args- args to pass to the function (optional)

Definition at line 25 of file vs_thread.h.

25  : std::thread(&thread::threadFunctionWrapper<Function, Args...>, this,
26  std::forward<Function>(f), std::forward<Args>(args)...) {
27  auto s = std::make_shared<Segment>(Revision::currentRevision->current);
28  threadRevision = std::make_shared<Revision>(Revision::currentRevision->current, s);
29  Revision::currentRevision->current->Release();
30  Revision::currentRevision->current = std::make_shared<Segment>(Revision::currentRevision->current);
31  }
static thread_local std::shared_ptr< Revision > currentRevision
The current Revision for current thread.
Definition: revision.h:65

Member Function Documentation

◆ join()

void vs::thread::join ( )
inline

Joins thread and it's Revision.

See also
Revision

Definition at line 38 of file vs_thread.h.

38  {
39  std::thread::join();
40 
41  std::shared_ptr<Segment> s = threadRevision->current;
42  while (s != threadRevision->root) {
43  for (auto v: s->written) {
44  v->Merge(Revision::currentRevision, threadRevision, s);
45  }
46  s = s->parent;
47  }
48 
49  threadRevision->current->Release();
51  }

The documentation for this class was generated from the following file: