-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessorGroup.h
More file actions
53 lines (38 loc) · 1.09 KB
/
ProcessorGroup.h
File metadata and controls
53 lines (38 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include "TypeUtilities.h"
namespace ndtech {
template<typename... ProcessorTypes>
struct ProcessorGroup {
~ProcessorGroup() {
std::cout << "~ProcessorGroup" << std::endl;
}
ProcessorGroup(ProcessorTypes&... processors) :
m_processors{ processors... }
{
}
void Start() {
m_thread = std::thread{ &ProcessorGroup::Run, this };
}
void Run() {
std::cout << "ProcessorGroup threadId = " << std::this_thread::get_id() << std::endl;
while (!m_done) {
Process();
}
}
void Process() {
TypeUtilities::ForTuple(
[](auto& processor) {
processor.Process();
},
m_processors);
}
void Join() {
this->m_done = true;
m_thread.join();
}
private:
std::thread m_thread;
std::tuple<ProcessorTypes&...> m_processors;
bool m_done = false;
};
}