Growing collection of utilities for parallel computing. More...
Classes | |
| class | sourcemeta::core::ParallelThreadError |
Functions | |
| template<typename Iterator, typename Callback> requires std::input_iterator<Iterator> && std::copyable<Iterator> && std::invocable<Callback, std::iter_reference_t<Iterator>, std::size_t, std::size_t> | |
| auto | sourcemeta::core::parallel_for_each (Iterator first, Iterator last, Callback &&callback, const std::size_t parallelism=std::thread::hardware_concurrency(), const std::size_t stack_size_bytes=0) -> void |
Growing collection of utilities for parallel computing.
This functionality is included as follows:
| class sourcemeta::core::ParallelThreadError |
An error that represents a worker thread the platform refused to create
Public Member Functions | |
|---|---|
| ParallelThreadError (const StaticString message) noexcept | |
| Construct an error with the given message. | |
| Public Member Functions inherited from sourcemeta::core::Error | |
| auto | message () const noexcept -> StaticString |
Additional Inherited Members | |
| Protected Member Functions inherited from sourcemeta::core::Error | |
| Error (const StaticString message) noexcept | |
| Construct the error given its message. | |
| auto sourcemeta::core::parallel_for_each | ( | Iterator | first, |
| Iterator | last, | ||
| Callback && | callback, | ||
| const std::size_t | parallelism = std::thread::hardware_concurrency(), | ||
| const std::size_t | stack_size_bytes = 0 ) -> void |
Process a collection in parallel. By default, parallelism uses the available number of cores. Setting parallelism to zero runs sequentially. When worker threads are created, a stack size of zero uses the platform default, and an unsupported stack size throws. Sequential execution uses the calling thread's stack. Single-pass iterators run sequentially and report an effective parallelism of one to the callback. For example: