From b8c1c136667c8d4ab679a571478fa653220a0b1f Mon Sep 17 00:00:00 2001 From: tamasmeszaros <meszaros.q@gmail.com> Date: Tue, 2 Mar 2021 18:20:11 +0100 Subject: [PATCH] Add max_concurrency method for various execution policies --- src/libslic3r/SLA/Concurrency.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/SLA/Concurrency.hpp b/src/libslic3r/SLA/Concurrency.hpp index b692914ac..8ff0ff809 100644 --- a/src/libslic3r/SLA/Concurrency.hpp +++ b/src/libslic3r/SLA/Concurrency.hpp @@ -5,6 +5,7 @@ #include <tbb/mutex.h> #include <tbb/parallel_for.h> #include <tbb/parallel_reduce.h> +#include <tbb/task_arena.h> #include <algorithm> #include <numeric> @@ -76,13 +77,18 @@ template<> struct _ccr<true> from, to, init, std::forward<MergeFn>(mergefn), [](typename I::value_type &i) { return i; }, granularity); } + + static size_t max_concurreny() + { + return tbb::this_task_arena::max_concurrency(); + } }; template<> struct _ccr<false> { private: struct _Mtx { inline void lock() {} inline void unlock() {} }; - + public: using SpinningMutex = _Mtx; using BlockingMutex = _Mtx; @@ -133,6 +139,8 @@ public: return reduce(from, to, init, std::forward<MergeFn>(mergefn), [](typename I::value_type &i) { return i; }); } + + static size_t max_concurreny() { return 1; } }; using ccr = _ccr<USE_FULL_CONCURRENCY>;