| 2191 | */ |
| 2192 | template <typename T, typename F, bool submit, typename N = std::conditional_t<submit, multi_future<void>, void>> |
| 2193 | [[nodiscard]] N enqueue_loop(const T first_index, const T index_after_last, F&& loop, std::size_t num_blocks, const priority_t priority = 0) |
| 2194 | { |
| 2195 | if (index_after_last > first_index) |
| 2196 | { |
| 2197 | using loop_task_t = loop_task<T, F>; |
| 2198 | const std::shared_ptr<std::decay_t<F>> loop_ptr = std::make_shared<std::decay_t<F>>(std::forward<F>(loop)); |
| 2199 | const blocks blks(first_index, index_after_last, num_blocks ? num_blocks : thread_count); |
| 2200 | num_blocks = blks.get_num_blocks(); |
| 2201 | std::vector<std::conditional_t<submit, loop_task_t, task_t>> all_tasks; |
| 2202 | all_tasks.reserve(num_blocks); |
| 2203 | for (std::size_t i = 0; i < num_blocks; ++i) |
| 2204 | all_tasks.emplace_back(loop_task_t{loop_ptr, blks.start(i), blks.end(i)}); |
| 2205 | if constexpr (submit) |
| 2206 | return submit_bulk(all_tasks, priority); |
| 2207 | else |
| 2208 | detach_bulk(all_tasks, priority); |
| 2209 | } |
| 2210 | return N(); |
| 2211 | } |
| 2212 | |
| 2213 | /** |
| 2214 | * @brief A helper function for `detach_sequence()` and `submit_sequence()`. |
nothing calls this directly
no test coverage detected