2025-07-24 19:35:51 +03:00
|
|
|
#pragma once
|
|
|
|
|
#include <execution>
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
#define POOLSTL_STD_SUPPLEMENT
|
|
|
|
|
#include <poolstl.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-07-27 16:30:45 +03:00
|
|
|
template <typename ContainerType> void parallel_loop_container(const ContainerType& c, std::function<void(const typename ContainerType::value_type&)> func, bool forceSingleThread = false) {
|
2025-07-24 19:35:51 +03:00
|
|
|
#ifdef __EMSCRIPTEN__
|
|
|
|
|
std::for_each(c.begin(), c.end(), func);
|
|
|
|
|
#else
|
2025-07-27 16:30:45 +03:00
|
|
|
if(forceSingleThread)
|
|
|
|
|
std::for_each(c.begin(), c.end(), func);
|
|
|
|
|
else
|
|
|
|
|
std::for_each(std::execution::par_unseq, c.begin(), c.end(), func);
|
2025-07-24 19:35:51 +03:00
|
|
|
#endif
|
|
|
|
|
}
|