Testing if submit nThreads pool task successfully.
102 {
103
105
106 auto func = [](int sec) -> bool
107 {
108 std::this_thread::sleep_for(std::chrono::seconds(sec));
109 return true;
110 };
111
112 std::vector<std::future<bool>> futures(nThreads);
113 for (int i = 0; i < nThreads; i++)
114 {
115 futures[i] = m_ThreadPool.SubmitPoolTask(std::bind(func, 2));
116 }
117
118 func(1);
119
120 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
121 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,0 );
123 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
124 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
125 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
126 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,true );
127
128
129 for (int i = 0; i < nThreads; i++)
130 {
131 futures[i].get();
132 }
133
134 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
135 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
137 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
138 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
139 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
140 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,true );
141 }
#define SPICESTEST_PROFILE_FUNCTION()