53template <
typename PoolType>
66 std::call_once(init_flag(), [num_threads] { thread_count() = num_threads; });
73 static PoolType pool(thread_count());
81 template <
typename F,
typename... Args>
85 return instance().submit(std::forward<F>(f), std::forward<Args>(args)...);
88 template <
typename F,
typename... Args>
92 return instance().try_submit(std::forward<F>(f), std::forward<Args>(args)...);
95 template <
typename F,
typename... Args>
97 post(F&& f, Args&&... args)
99 instance().post(std::forward<F>(f), std::forward<Args>(args)...);
102 template <
typename F,
typename... Args>
106 return instance().try_post(std::forward<F>(f), std::forward<Args>(args)...);
109 template <
typename Iterator>
113 return instance().submit_batch(begin, end);
116 template <
typename Iterator>
120 return instance().try_submit_batch(begin, end);
123 template <
typename Iterator,
typename F>
127 instance().parallel_for_each(begin, end, std::forward<F>(func));
136 init_flag() -> std::once_flag&
138 static std::once_flag flag;
143 thread_count() ->
size_t&
183template <
typename Container,
typename F>
Singleton accessor for a process-wide pool instance.
static auto try_submit(F &&f, Args &&... args)
static void parallel_for_each(Iterator begin, Iterator end, F &&func)
static auto instance() -> PoolType &
Access the singleton pool instance (created on first call).
static auto try_post(F &&f, Args &&... args)
static void init(size_t num_threads)
Pre-configure the number of threads before first use.
static auto try_submit_batch(Iterator begin, Iterator end)
static auto submit_batch(Iterator begin, Iterator end)
static auto submit(F &&f, Args &&... args)
static void post(F &&f, Args &&... args)
Aggregates multiple thread_registry_backend instances into a single queryable view.
void parallel_for_each(Container &container, F &&func)
Convenience wrapper that applies a callable to every element of a container in parallel using the glo...
auto default_worker_count() noexcept -> std::size_t
Shared-queue pool implementation and public detail aliases.
Work-stealing deque and pool implementation.
Worker-thread count configuration for pool types.