#include #include #include #include /// Test for thread self-removal when number of free threads in pool is too large. /// Just checks that nothing weird happens. template int test() { Pool pool(10, 2, 10); std::atomic counter{0}; for (size_t i = 0; i < 10; ++i) pool.scheduleOrThrowOnError([&]{ ++counter; }); pool.wait(); return counter; } TEST(ThreadPool, ThreadRemoval) { EXPECT_EQ(test(), 10); EXPECT_EQ(test(), 10); }