72 auto * q = &(
state->queue);
73 for (
size_t i = 0; i < thread_count; ++i)
81 if (q->wait_pop(task) == contrib::queue_op_status::closed)
133 template <std::copy_constructible algorithm_t,
typename algorithm_input_t, std::copy_constructible callback_t>
134 requires std::invocable<algorithm_t, algorithm_input_t, callback_t>
135 && (std::is_lvalue_reference_v<algorithm_input_t> || std::move_constructible<algorithm_input_t>)
136 void execute(algorithm_t && algorithm, algorithm_input_t && input, callback_t && callback)
138 assert(
state !=
nullptr);
156 using forward_input_t = std::tuple_element_t<0,
decltype(input_tpl)>;
157 algorithm(std::forward<forward_input_t>(std::get<0>(input_tpl)), std::move(callback));
160 [[maybe_unused]] contrib::queue_op_status status =
state->queue.wait_push(std::move(task));
161 assert(status == contrib::queue_op_status::success);
180 template <std::copy_constructible algorithm_t,
181 std::ranges::input_range algorithm_input_range_t,
182 std::copy_constructible callback_t>
183 requires std::invocable<algorithm_t, std::ranges::range_reference_t<algorithm_input_range_t>, callback_t>
184 void bulk_execute(algorithm_t && algorithm, algorithm_input_range_t && input_range, callback_t && callback)
186 for (
auto && input : input_range)
195 assert(
state !=
nullptr);
197 state->stop_and_wait();
251 contrib::fixed_buffer_queue<task_type>
queue{10000};
Provides various type traits on generic types.
Provides seqan3::buffer_queue.
An internal state stored on the heap to allow safe move construction/assignment of the class.
Definition execution_handler_parallel.hpp:210
internal_state(internal_state &&)=delete
Deleted.
internal_state()=default
Defaulted.
~internal_state()
Waits for threads to finish.
Definition execution_handler_parallel.hpp:223
contrib::fixed_buffer_queue< task_type > queue
The concurrent queue containing the algorithms to process.
Definition execution_handler_parallel.hpp:251
internal_state & operator=(internal_state const &)=delete
Deleted.
void stop_and_wait()
Waits until all threads have been joined.
Definition execution_handler_parallel.hpp:237
internal_state(internal_state const &)=delete
Deleted.
internal_state & operator=(internal_state &&)=delete
Deleted.
std::vector< std::thread > thread_pool
The thread pool.
Definition execution_handler_parallel.hpp:249
Handles the parallel execution of algorithms.
Definition execution_handler_parallel.hpp:52
~execution_handler_parallel()=default
Defaulted.
execution_handler_parallel(execution_handler_parallel const &)=delete
Deleted.
execution_handler_parallel & operator=(execution_handler_parallel &&)=default
Defaulted.
void wait()
Waits until all submitted algorithm jobs have been completed.
Definition execution_handler_parallel.hpp:193
std::unique_ptr< internal_state > state
Manages the internal state.
Definition execution_handler_parallel.hpp:255
execution_handler_parallel(size_t const thread_count)
Constructs the execution handler spawning thread_count many threads.
Definition execution_handler_parallel.hpp:70
void bulk_execute(algorithm_t &&algorithm, algorithm_input_range_t &&input_range, callback_t &&callback)
Asynchronously executes the algorithm for every element of the given input range.
Definition execution_handler_parallel.hpp:184
void execute(algorithm_t &&algorithm, algorithm_input_t &&input, callback_t &&callback)
Asynchronously schedules a new algorithm task with the given input and callback.
Definition execution_handler_parallel.hpp:136
execution_handler_parallel(execution_handler_parallel &&)=default
Defaulted.
execution_handler_parallel()
Constructs the execution handler spawning 1 thread.
Definition execution_handler_parallel.hpp:104
execution_handler_parallel & operator=(execution_handler_parallel const &)=delete
Deleted.
T emplace_back(T... args)
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
SeqAn specific customisations in the standard namespace.
Provides seqan3::detail::reader_writer_manager.