Block a number of worker threads by submitting tasks that wait on `release_sem`. Returns the futures of the blocking tasks, ensuring all have started and are waiting.
| 65 | // Block a number of worker threads by submitting tasks that wait on `release_sem`. |
| 66 | // Returns the futures of the blocking tasks, ensuring all have started and are waiting. |
| 67 | std::vector<std::future<void>> BlockWorkers(ThreadPool& threadPool, std::counting_semaphore<>& release_sem, size_t num_of_threads_to_block) |
| 68 | { |
| 69 | assert(threadPool.WorkersCount() >= num_of_threads_to_block); |
| 70 | std::latch ready{static_cast<std::ptrdiff_t>(num_of_threads_to_block)}; |
| 71 | std::vector<std::future<void>> blocking_tasks(num_of_threads_to_block); |
| 72 | for (auto& f : blocking_tasks) f = Submit(threadPool, [&] { |
| 73 | ready.count_down(); |
| 74 | release_sem.acquire(); |
| 75 | }); |
| 76 | ready.wait(); |
| 77 | return blocking_tasks; |
| 78 | } |
| 79 | |
| 80 | // Test 0, submit task to a non-started, interrupted, or stopped pool |
| 81 | BOOST_AUTO_TEST_CASE(submit_fails_with_correct_error) |
no test coverage detected