OoOJoin  0.0.1
The next generation of out-of-order join operator
AbstractC20Thread.hpp
Go to the documentation of this file.
1 
2 //
3 // Created by tony on 07/03/22.
4 //
5 
6 #ifndef _INCLUDE_UTILS_ABSTRACTC20THREAD_H_
7 #define _INCLUDE_UTILS_ABSTRACTC20THREAD_H_
8 #pragma once
9 #include <thread>
10 #include <memory>
11 #include <barrier>
22 namespace INTELLI {
30  protected:
35  virtual void inlineMain() {
36 
37  }
38 
39  std::shared_ptr<std::thread> threadPtr;
40  public:
42  ~AbstractC20Thread() {}
46  void startThread() {
47  auto fun = [this]() {
48  inlineMain();
49  };
50  threadPtr = std::make_shared<std::thread>(fun);
51  // table=make_shared<MultiThreadHashTable>(5000);
52  }
56  void joinThread() {
57  threadPtr->join();
58  }
59 
60 };
66 typedef std::shared_ptr<AbstractC20Thread> AbstractC20ThreadPtr;
72 #define newAbstractC20Thread make_shared<INTELLI::AbstractC20Thread>
73 typedef std::shared_ptr<std::barrier<>> BarrierPtr;
74 }
75 
76 
77 
84 #endif //ALIANCEDB_INCLUDE_UTILS_ABSTRACTTHREAD_H_
The base class and abstraction of C++20 thread, and it can be derived into other threads.
Definition: AbstractC20Thread.hpp:29
virtual void inlineMain()
The inline 'main" function of thread, as an interface.
Definition: AbstractC20Thread.hpp:35
void startThread()
to start this thread
Definition: AbstractC20Thread.hpp:46
void joinThread()
the thread join function
Definition: AbstractC20Thread.hpp:56
std::shared_ptr< AbstractC20Thread > AbstractC20ThreadPtr
The class to describe a shared pointer to AbstractC20Thread.
Definition: AbstractC20Thread.hpp:66