SpiecsEngine
 
Loading...
Searching...
No Matches

◆ TEST_F() [67/72]

SpicesTest::TEST_F ( ThreadPoolFixed_test ,
SubmitVeryMuchAnyTask  )

Testing if submit very much mixed task successfully.

Definition at line 482 of file ThreadPoolFixed_test.h.

482 {
483
485
486 auto func = []() -> void
487 {
488 std::this_thread::sleep_for(std::chrono::microseconds(1));
489 };
490
491 for (int i = 0; i < 5000; i++)
492 {
493 m_ThreadPool.SubmitPoolTask(func);
494 }
495
496 for (int i = 0; i < 1000; i++)
497 {
498 m_ThreadPool.SubmitThreadTask_LightWeight_ForEach(func);
499 }
500
501 /* @brief Wait for all tasks finish. */
502 m_ThreadPool.Wait();
503
504 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
505 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
506 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_FIXED );
507 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
508 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
509 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),Spices::THREAD_MAX_IDLE_TIME );
510 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,true );
511
512 for (auto& pair : m_ThreadPool.GetThreads())
513 {
514 EXPECT_EQ(pair.second->GetThreadTasksCount(),0);
515 }
516 }
#define SPICESTEST_PROFILE_FUNCTION()
constexpr uint32_t THREAD_MAX_IDLE_TIME