diff --git a/tests/tests.cpp b/tests/tests.cpp index f786fbc8..18facbd7 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -2450,6 +2450,11 @@ test_tp_heavy_repeated_construct_destroy() std::this_thread::sleep_for(std::chrono::microseconds(25)); counter.fetch_add(1); }); + + // ~ThreadPool cancels its workers without draining the queue, + // so let the work finish before the pool is destroyed. + TEST_CHECK(wait_until([&counter]() { return counter.load() == 400; }, + 30000)); } TEST_CHECK(counter.load() == 400);