-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThread_Pool.hpp
More file actions
44 lines (38 loc) · 923 Bytes
/
Thread_Pool.hpp
File metadata and controls
44 lines (38 loc) · 923 Bytes
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
#include <iostream>
#include <vector>
#include <thread>
using namespace std;
class Thread_Pool {
public:
vector<thread> Pool;
int wait_for_pool() {
for (thread& t : Pool) {
t.join();
}
return 0;
}
int start_pool(int number, int (*target)(int), int arg) {
for (int i{ 0 }; i < number; i++) {
loop:
try {
Pool.emplace_back(target, arg);
}
catch (...) {
for (int w{ 0 }; w < 700000;w++);
goto loop;
}
}
return 0;
}
int start_thread(int Network_Scan::*target, string sarg) {
start:
try {
Pool.emplace_back(target, sarg);
}
catch (...){
for (int w{ 0 }; w < 700000;w++);
goto start;
}
return 0;
}
};