Testing if submit 2 nThreads pool task successfully.
272 {
273
275
276 auto func = [](int sec) -> bool
277 {
278 std::this_thread::sleep_for(std::chrono::seconds(sec));
279 return true;
280 };
281
282 std::vector<std::future<bool>> futures(2 * nThreads);
283 for (int i = 0; i < 2 * nThreads; i++)
284 {
285 futures[i] = m_ThreadPool.SubmitPoolTask(std::bind(func, 2));
286 }
287
288 func(1);
289
290 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
291 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,0 );
293 EXPECT_EQ(m_ThreadPool.GetTasks() ,nThreads );
294 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
296 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,true );
297
298 func(2);
299
300 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
301 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,0 );
303 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
304 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
306 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,true );
307
308
309 m_ThreadPool.Wait();
310
311 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
312 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
314 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
315 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
317 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,true );
318 }
#define SPICESTEST_PROFILE_FUNCTION()
constexpr uint32_t THREAD_MAX_IDLE_TIME