* @brief Check that wait() works. */
| 1425 | * @brief Check that wait() works. |
| 1426 | */ |
| 1427 | void check_wait() |
| 1428 | { |
| 1429 | constexpr std::chrono::milliseconds sleep_time(10); |
| 1430 | BS::thread_pool pool; |
| 1431 | const std::size_t num_tasks = pool.get_thread_count() * 10; |
| 1432 | std::vector<std::atomic<bool>> flags(num_tasks); |
| 1433 | for (std::size_t i = 0; i < num_tasks; ++i) |
| 1434 | { |
| 1435 | pool.detach_task( |
| 1436 | [&flags, i, sleep_time] |
| 1437 | { |
| 1438 | std::this_thread::sleep_for(sleep_time); |
| 1439 | flags[i] = true; |
| 1440 | }); |
| 1441 | } |
| 1442 | logln("Waiting for tasks..."); |
| 1443 | pool.wait(); |
| 1444 | check(all_flags_set(flags)); |
| 1445 | } |
| 1446 | |
| 1447 | /** |
| 1448 | * @brief Check that wait() correctly blocks all external threads that call it. |
no test coverage detected