* @brief Check that detach_blocks() and submit_blocks() work using several different random values for the range of indices and number of tasks. */
| 1812 | * @brief Check that detach_blocks() and submit_blocks() work using several different random values for the range of indices and number of tasks. |
| 1813 | */ |
| 1814 | void check_blocks() |
| 1815 | { |
| 1816 | constexpr std::int64_t range = 1000000; |
| 1817 | constexpr std::size_t repeats = 10; |
| 1818 | BS::thread_pool pool; |
| 1819 | for (std::size_t i = 0; i < repeats; ++i) |
| 1820 | { |
| 1821 | const std::pair<std::int64_t, std::int64_t> indices = random_pair(-range, range); |
| 1822 | check(check_blocks_no_return(pool, indices.first, indices.second, random<std::size_t>(1, pool.get_thread_count()), "detach_blocks()")); |
| 1823 | } |
| 1824 | for (std::size_t i = 0; i < repeats; ++i) |
| 1825 | { |
| 1826 | const std::pair<std::int64_t, std::int64_t> indices = random_pair(-range, range); |
| 1827 | check(check_blocks_no_return(pool, indices.first, indices.second, random<std::size_t>(1, pool.get_thread_count()), "submit_blocks()")); |
| 1828 | } |
| 1829 | for (std::size_t i = 0; i < repeats; ++i) |
| 1830 | { |
| 1831 | const std::pair<std::int64_t, std::int64_t> indices = random_pair(-range, range); |
| 1832 | check_blocks_return(pool, indices.first, indices.second, random<std::size_t>(1, pool.get_thread_count())); |
| 1833 | } |
| 1834 | logln("Verifying that detach_blocks() with identical start and end indices does nothing..."); |
| 1835 | { |
| 1836 | std::atomic<std::size_t> count = 0; |
| 1837 | const std::int64_t index = random(-range, range); |
| 1838 | logln("Range: ", index, " to ", index); |
| 1839 | pool.detach_blocks(index, index, |
| 1840 | [&count](const std::int64_t, const std::int64_t) |
| 1841 | { |
| 1842 | ++count; |
| 1843 | }); |
| 1844 | pool.wait(); |
| 1845 | check(count == 0); |
| 1846 | } |
| 1847 | logln("Verifying that submit_blocks() with identical start and end indices does nothing..."); |
| 1848 | { |
| 1849 | std::atomic<std::size_t> count = 0; |
| 1850 | const std::int64_t index = random(-range, range); |
| 1851 | logln("Range: ", index, " to ", index); |
| 1852 | pool.submit_blocks(index, index, |
| 1853 | [&count](const std::int64_t, const std::int64_t) |
| 1854 | { |
| 1855 | ++count; |
| 1856 | }) |
| 1857 | .wait(); |
| 1858 | check(count == 0); |
| 1859 | } |
| 1860 | logln("Verifying that detach_blocks() with end index smaller than the start index does nothing..."); |
| 1861 | { |
| 1862 | std::atomic<std::size_t> count = 0; |
| 1863 | const std::pair<std::int64_t, std::int64_t> indices = random_pair(-range, range); |
| 1864 | logln("Range: ", indices.second, " to ", indices.first); |
| 1865 | pool.detach_blocks(indices.second, indices.first, |
| 1866 | [&count](const std::int64_t, const std::int64_t) |
| 1867 | { |
| 1868 | ++count; |
| 1869 | }); |
| 1870 | pool.wait(); |
| 1871 | check(count == 0); |
no test coverage detected