* @brief Check that reset() works. */
| 828 | * @brief Check that reset() works. |
| 829 | */ |
| 830 | void check_reset() |
| 831 | { |
| 832 | BS::thread_pool pool; |
| 833 | pool.reset(static_cast<std::size_t>(std::thread::hardware_concurrency()) * 2); |
| 834 | logln("Checking that after reset() the thread pool reports a number of threads equal to double the hardware concurrency..."); |
| 835 | check(std::thread::hardware_concurrency() * 2, pool.get_thread_count()); |
| 836 | logln("Checking that after reset() the manually counted number of unique thread IDs is equal to the reported number of threads..."); |
| 837 | check(pool.get_thread_count(), obtain_unique_threads(pool).size()); |
| 838 | pool.reset(std::thread::hardware_concurrency()); |
| 839 | logln("Checking that after a second reset() the thread pool reports a number of threads equal to the hardware concurrency..."); |
| 840 | check(std::thread::hardware_concurrency(), pool.get_thread_count()); |
| 841 | logln("Checking that after a second reset() the manually counted number of unique thread IDs is equal to the reported number of threads..."); |
| 842 | check(pool.get_thread_count(), obtain_unique_threads(pool).size()); |
| 843 | } |
| 844 | |
| 845 | // ======================================= |
| 846 | // Functions to verify submission of tasks |