26namespace seqan3::detail
54class execution_handler_parallel
73 execution_handler_parallel(
size_t const thread_count) : state{
std::
make_unique<internal_state>()}
75 auto * q = &(state->queue);
76 for (
size_t i = 0; i < thread_count; ++i)
78 state->thread_pool.emplace_back([q] ()
83 if (q->wait_pop(task) == contrib::queue_op_status::closed)
106 execution_handler_parallel() : execution_handler_parallel{1u}
109 execution_handler_parallel(execution_handler_parallel
const &) =
delete;
110 execution_handler_parallel(execution_handler_parallel &&) =
default;
111 execution_handler_parallel & operator=(execution_handler_parallel
const &) =
delete;
112 execution_handler_parallel & operator=(execution_handler_parallel &&) =
default;
113 ~execution_handler_parallel() =
default;
135 template <std::copy_constructible algorithm_t,
136 typename algorithm_input_t,
137 std::copy_constructible callback_t>
139 requires std::invocable<algorithm_t, algorithm_input_t, callback_t> &&
140 (std::is_lvalue_reference_v<algorithm_input_t> || std::move_constructible<algorithm_input_t>)
142 void execute(algorithm_t && algorithm, algorithm_input_t && input, callback_t && callback)
144 assert(state !=
nullptr);
160 using forward_input_t = std::tuple_element_t<0,
decltype(input_tpl)>;
161 algorithm(std::forward<forward_input_t>(std::get<0>(input_tpl)), std::move(callback));
164 [[maybe_unused]] contrib::queue_op_status
status = state->queue.wait_push(std::move(task));
165 assert(status == contrib::queue_op_status::success);
184 template <std::copy_constructible algorithm_t,
185 std::ranges::input_range algorithm_input_range_t,
186 std::copy_constructible callback_t>
188 requires std::invocable<algorithm_t, std::ranges::range_reference_t<algorithm_input_range_t>, callback_t>
190 void bulk_execute(algorithm_t && algorithm, algorithm_input_range_t && input_range, callback_t && callback)
192 for (
auto && input : input_range)
193 execute(algorithm,
std::forward<
decltype(input)>(input), callback);
201 assert(state !=
nullptr);
203 state->stop_and_wait();
222 internal_state() =
default;
223 internal_state(internal_state
const &) =
delete;
224 internal_state(internal_state &&) =
default;
225 internal_state & operator=(internal_state
const &) =
delete;
226 internal_state & operator=(internal_state &&) =
default;
247 for (
auto & t : thread_pool)
257 contrib::fixed_buffer_queue<task_type> queue{10000};
Provides various type traits on generic types.
Provides seqan3::buffer_queue.
The <concepts> header from C++20's standard library.
SeqAn specific customisations in the standard namespace.
The <ranges> header from C++20's standard library.
Provides seqan3::detail::reader_writer_manager.