-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
41 lines (36 loc) · 686 Bytes
/
main.cpp
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
#include <iostream>
#include "DynamicPool.h"
#include "ThreadPool.h"
#include "UTestCase.h"
using namespace std;
bool sleep500ms()
{
this_thread::sleep_for(500ms);
return true;
}
int main()
{
UTestCase p1("ThreadPool", [] {
ThreadPool pool;
for (int i = 1; i <= 500; ++i)
{
UTestCase t("test" + to_string(i), sleep500ms);
pool.enqueue([t]() mutable { t(); cout << t; });
}
return true;
});
p1();
cout << p1;
UTestCase p2("DynamicPool", [] {
DynamicPool pool;
for (int i = 1; i <= 500; ++i)
{
UTestCase t("test" + to_string(i), sleep500ms);
pool.enqueue([t]() mutable { t(); cout << t; });
}
return true;
});
p2();
cout << p2;
return 0;
}