edit
[c11concurrency-benchmarks.git] / silo / thread.cc
1 #include "macros.h"
2 #include "thread.h"
3
4 using namespace std;
5
6 ndb_thread::~ndb_thread()
7 {
8 }
9
10 void
11 ndb_thread::start()
12 {
13   thd_ = std::move(thread(&ndb_thread::run, this));
14   if (daemon_)
15     thd_.detach();
16 }
17
18 void
19 ndb_thread::join()
20 {
21   ALWAYS_ASSERT(!daemon_);
22   thd_.join();
23 }
24
25 // can be overloaded by subclasses
26 void
27 ndb_thread::run()
28 {
29   ALWAYS_ASSERT(body_);
30   body_();
31 }