@@ -11414,6 +11414,35 @@ auto transform_parallelly_n_threads(std::size_t n, F f, const ContainerIn& xs)
1141411414 thread_results);
1141511415}
1141611416
11417+ // API search type: transform_convert_parallelly : ((a -> b), [a]) -> [b]
11418+ // fwd bind count: 1
11419+ // transform_convert_parallelly((*2), [1, 3, 4]) == [2, 6, 8]
11420+ // Same as transform_convert, but can utilize multiple CPUs by using std::launch::async.
11421+ // Only makes sense if one run of the provided function
11422+ // takes enough time to justify the synchronization overhead.
11423+ // One thread per container element is spawned.
11424+ template <typename ContainerOut, typename F, typename ContainerIn>
11425+ ContainerOut transform_convert_parallelly(F f, const ContainerIn& xs)
11426+ {
11427+ using X = typename ContainerIn::value_type;
11428+ internal::trigger_static_asserts<internal::unary_function_tag, F, X>();
11429+ auto handles = transform([&f](const X& x) {
11430+ return std::async(std::launch::async, [&x, &f]() {
11431+ return internal::invoke(f, x);
11432+ });
11433+ },
11434+ xs);
11435+
11436+ internal::trigger_static_asserts<internal::unary_function_tag, F, typename ContainerIn::value_type>();
11437+ ContainerOut ys;
11438+ internal::prepare_container(ys, size_of_cont(xs));
11439+ auto it = internal::get_back_inserter<ContainerOut>(ys);
11440+ for (auto& handle : handles) {
11441+ *it = handle.get();
11442+ }
11443+ return ys;
11444+ }
11445+
1141711446// API search type: reduce_parallelly : (((a, a) -> a), a, [a]) -> a
1141811447// fwd bind count: 2
1141911448// reduce_parallelly((+), 0, [1, 2, 3]) == (0+1+2+3) == 6
@@ -15159,6 +15188,7 @@ fplus_curry_define_fn_1(apply_functions)
1515915188fplus_curry_define_fn_2(apply_function_n_times)
1516015189fplus_curry_define_fn_1(transform_parallelly)
1516115190fplus_curry_define_fn_2(transform_parallelly_n_threads)
15191+ fplus_curry_define_fn_1(transform_convert_parallelly)
1516215192fplus_curry_define_fn_2(reduce_parallelly)
1516315193fplus_curry_define_fn_3(reduce_parallelly_n_threads)
1516415194fplus_curry_define_fn_1(reduce_1_parallelly)
@@ -15768,6 +15798,7 @@ fplus_fwd_define_fn_1(apply_functions)
1576815798fplus_fwd_define_fn_2(apply_function_n_times)
1576915799fplus_fwd_define_fn_1(transform_parallelly)
1577015800fplus_fwd_define_fn_2(transform_parallelly_n_threads)
15801+ fplus_fwd_define_fn_1(transform_convert_parallelly)
1577115802fplus_fwd_define_fn_2(reduce_parallelly)
1577215803fplus_fwd_define_fn_3(reduce_parallelly_n_threads)
1577315804fplus_fwd_define_fn_1(reduce_1_parallelly)
@@ -16057,6 +16088,7 @@ fplus_fwd_flip_define_fn_1(shuffle)
1605716088fplus_fwd_flip_define_fn_1(random_element)
1605816089fplus_fwd_flip_define_fn_1(apply_functions)
1605916090fplus_fwd_flip_define_fn_1(transform_parallelly)
16091+ fplus_fwd_flip_define_fn_1(transform_convert_parallelly)
1606016092fplus_fwd_flip_define_fn_1(reduce_1_parallelly)
1606116093fplus_fwd_flip_define_fn_1(keep_if_parallelly)
1606216094fplus_fwd_flip_define_fn_1(show_cont_with)
0 commit comments