blob: 94db50fc826550ea68f0ca8b5b12677387961710 (
plain)
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
|
#include <sys/types.h>
#include <thread>
#include <unistd.h>
#include <vector>
template <typename T>
void launcher(T func) {
std::vector<std::thread> pool;
for (int i = 0; i < 10; i++) {
pool.emplace_back(std::thread(func));
}
for (auto &t : pool) {
t.join();
}
}
void h() {}
void g() {
fork();
launcher<>(h);
}
void f() {
fork();
launcher<>(g);
}
int main() {
launcher<>(f);
return 0;
}
|