infinipaint/include/Helpers/Parallel.hpp

18 lines
583 B
C++
Raw Normal View History

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) {
2026-02-24 17:21:41 +03:00
#if defined(__EMSCRIPTEN__) || defined(__ANDROID__)
2025-07-24 19:35:51 +03:00
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
}