-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy paththread_pool_test.cpp
More file actions
35 lines (30 loc) · 835 Bytes
/
thread_pool_test.cpp
File metadata and controls
35 lines (30 loc) · 835 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
#include <iostream>
#include <windows.h>
#include "thread_pool.h"
int func(unsigned int n)
{
Sleep(1000 * n);
return n;
}
int main()
{
ThreadPool thread_pool(4);
auto r1 = thread_pool.commit(func, 1);
auto r2 = thread_pool.commit(func, 2);
auto r3 = thread_pool.commit(func, 3);
auto r4 = thread_pool.commit(func, 4);
auto r5 = thread_pool.commit(func, 5);
auto r6 = thread_pool.commit(func, 10);
auto r7 = thread_pool.commit(func, 20);
auto r8 = thread_pool.commit(func, 30);
std::cout << r1.get() << std::endl;
std::cout << r2.get() << std::endl;
std::cout << r3.get() << std::endl;
std::cout << r4.get() << std::endl;
std::cout << r5.get() << std::endl;
std::cout << r6.get() << std::endl;
std::cout << r7.get() << std::endl;
std::cout << r8.get() << std::endl;
std::cout << "END" << std::endl;
return 0;
}