@@ -128,28 +128,28 @@ auto parallel_for_range(size_t start, size_t end, FunctionType f, size_t cpu_num
128128 return ret;
129129}
130130
131- template <typename FunctionType>
132- void parallel_for_index_void_steal (size_t start, size_t end, FunctionType f, int cpu_num = 0 ) {
131+ template <typename FunctionType, class TaskGroup = ThreadPool >
132+ void parallel_for_index_void_single (size_t start, size_t end, FunctionType f, int cpu_num = 0 ) {
133133 if (start >= end) {
134134 return ;
135135 }
136136
137- StealThreadPool tg (cpu_num == 0 ? std::thread::hardware_concurrency () : cpu_num);
137+ TaskGroup tg (cpu_num == 0 ? std::thread::hardware_concurrency () : cpu_num);
138138 for (size_t i = start; i < end; i++) {
139139 tg.submit ([func = f, i]() { func (i); });
140140 }
141141 tg.join ();
142142 return ;
143143}
144144
145- template <typename FunctionType>
146- auto parallel_for_index_steal (size_t start, size_t end, FunctionType f, size_t cpu_num = 0 ) {
145+ template <typename FunctionType, class TaskGroup = ThreadPool >
146+ auto parallel_for_index_single (size_t start, size_t end, FunctionType f, size_t cpu_num = 0 ) {
147147 std::vector<typename std::invoke_result<FunctionType, size_t >::type> ret;
148148 if (start >= end) {
149149 return ret;
150150 }
151151
152- StealThreadPool tg (cpu_num == 0 ? std::thread::hardware_concurrency () : cpu_num);
152+ TaskGroup tg (cpu_num == 0 ? std::thread::hardware_concurrency () : cpu_num);
153153 std::vector<std::future<typename std::invoke_result<FunctionType, size_t >::type>> tasks;
154154 for (size_t i = start; i < end; i++) {
155155 tasks.emplace_back (tg.submit ([func = f, i]() { return func (i); }));
0 commit comments