Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
52 lines (44 loc) · 1.49 KB

File metadata and controls

52 lines (44 loc) · 1.49 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
45
46
47
48
49
50
51
52
#include <gtest/gtest.h>
#include <cppcode/common/ThreadPool.hpp>
#include <vector>
TEST(ThreadPoolTest, test)
{
using cppcode::common::ThreadPool;
ThreadPool pool{4};
auto result1 = pool.push([](){
std::cout << "doing task 1" << std::endl;
std::this_thread::sleep_for(std::chrono::duration<double>(1));
return 1;
});
auto result2 = pool.push([](uint32_t value){
std::cout << "doing task 2" << std::endl;
std::this_thread::sleep_for(std::chrono::duration<double>(1));
return value;
}, 2);
auto result3 = pool.push([](){
std::cout << "doing task 3" << std::endl;
std::this_thread::sleep_for(std::chrono::duration<double>(1));
return 3;
});
auto result4 = pool.push([](){
std::cout << "doing task 4" << std::endl;
std::this_thread::sleep_for(std::chrono::duration<double>(1));
return 4;
});
std::this_thread::sleep_for(std::chrono::duration<double>(1));
auto result5 = pool.push([](){
std::cout << "doing task 5" << std::endl;
std::this_thread::sleep_for(std::chrono::duration<double>(1));
return 5;
});
std::this_thread::sleep_for(std::chrono::duration<double>(1));
EXPECT_EQ(result1.get(), 1);
EXPECT_EQ(result2.get(), 2);
EXPECT_EQ(result3.get(), 3);
EXPECT_EQ(result4.get(), 4);
EXPECT_EQ(result5.get(), 5);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.