-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
39 lines (31 loc) · 806 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
#include <chrono>
#include <iostream>
#include "TPScheduler.h"
int main()
{
// must make sure the pool is destroyed after the scheduler
KTP::ThreadPool pool1(5);
KTP::TPScheduler scheduler(1, 10, 1000);
auto tp1 = scheduler.Hosting(&pool1);
for (int i = 0; i < 100000; i++)
{
auto t2 = scheduler.Submit<KTP::Normal>([]()
{ return 2; });
}
scheduler.UnHosting(tp1);
// KTP::ThreadPool pool1(10);
//
// auto t1 = pool1.Submit<KTP::Normal>([]()
// { return; });
// auto t2 = pool1.Submit<KTP::Normal>([]()
// { return 2; });
//
// auto res1 = pool1.WaitTasksDone(t1, t2);
//
// auto t3 = pool1.Submit<KTP::Sequence>([]()
// { return 3; },
// []()
// { return 4; });
// auto res2 = pool1.WaitTasksDone(t3);
return 0;
}