| 2156 | */ |
| 2157 | template <typename T, typename F, typename R, bool submit, typename N = std::conditional_t<submit, multi_future<R>, void>> |
| 2158 | [[nodiscard]] N enqueue_blocks(const T first_index, const T index_after_last, F&& block, std::size_t num_blocks, const priority_t priority = 0) |
| 2159 | { |
| 2160 | if (index_after_last > first_index) |
| 2161 | { |
| 2162 | using block_task_t = block_task<T, F, R>; |
| 2163 | const std::shared_ptr<std::decay_t<F>> block_ptr = std::make_shared<std::decay_t<F>>(std::forward<F>(block)); |
| 2164 | const blocks blks(first_index, index_after_last, num_blocks ? num_blocks : thread_count); |
| 2165 | num_blocks = blks.get_num_blocks(); |
| 2166 | std::vector<std::conditional_t<submit, block_task_t, task_t>> all_tasks; |
| 2167 | all_tasks.reserve(num_blocks); |
| 2168 | for (std::size_t i = 0; i < num_blocks; ++i) |
| 2169 | all_tasks.emplace_back(block_task_t{block_ptr, blks.start(i), blks.end(i)}); |
| 2170 | if constexpr (submit) |
| 2171 | return submit_bulk(all_tasks, priority); |
| 2172 | else |
| 2173 | detach_bulk(all_tasks, priority); |
| 2174 | } |
| 2175 | return N(); |
| 2176 | } |
| 2177 | |
| 2178 | /** |
| 2179 | * @brief A helper function for `detach_loop()` and `submit_loop()`. |
nothing calls this directly
no test coverage detected