diff --git a/src/libslic3r/Execution/Execution.hpp b/src/libslic3r/Execution/Execution.hpp index 62e49cfeb3..dcfd86bde8 100644 --- a/src/libslic3r/Execution/Execution.hpp +++ b/src/libslic3r/Execution/Execution.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "libslic3r/libslic3r.h" @@ -44,7 +45,8 @@ size_t max_concurrency(const EP &ep) template> void for_each(const EP &ep, It from, It to, Fn &&fn, size_t granularity = 1) { - AsTraits::for_each(ep, from, to, std::forward(fn), granularity); + AsTraits::for_each(ep, from, to, std::forward(fn), + std::max(granularity, size_t(1))); } // A reduce operation with the execution policy passed as argument. @@ -68,7 +70,7 @@ T reduce(const EP & ep, return AsTraits::reduce(ep, from, to, init, std::forward(mergefn), std::forward(accessfn), - granularity); + std::max(granularity, size_t(1))); } // An overload of reduce method to be used with iterators as 'from' and 'to' @@ -87,7 +89,7 @@ T reduce(const EP &ep, { return reduce( ep, from, to, init, std::forward(mergefn), - [](const auto &i) { return i; }, granularity); + [](const auto &i) { return i; }, std::max(granularity, size_t(1))); } template{}, - std::forward(accessfn), granularity); + std::forward(accessfn), + std::max(granularity, size_t(1))); } @@ -119,7 +122,7 @@ T accumulate(const EP &ep, { return reduce( ep, from, to, init, std::plus{}, [](const auto &i) { return i; }, - granularity); + std::max(granularity, size_t(1))); } } // namespace execution_policy