60 if (!n || !options.maxThreads || detail::PerPoolPerThreadInfo::isParForRecursive(&tasks.pool())) {
61 for (
size_t i = 0; i < n; ++i) {
72 int32_t maxThreads = std::max<int32_t>(options.maxThreads, 1);
74 ssize_t numThreads = std::min<ssize_t>(tasks.numPoolThreads() + options.wait, maxThreads);
76 numThreads = std::min<ssize_t>(numThreads, n);
78 auto chunking = detail::staticChunkSize(n, numThreads);
79 size_t chunkSize = chunking.ceilChunkSize;
81 bool perfectlyChunked = chunking.transitionTaskIndex == numThreads;
84 ssize_t firstLoopLen = chunking.transitionTaskIndex - perfectlyChunked;
87 for (t = 0; t < firstLoopLen; ++t) {
89 std::advance(next, chunkSize);
90 tasks.schedule([start, next, f]() {
91 auto recurseInfo = detail::PerPoolPerThreadInfo::parForRecurse();
92 for (Iter it = start; it != next; ++it) {
100 chunkSize -= !perfectlyChunked;
102 for (; t < numThreads - 1; ++t) {
104 std::advance(next, chunkSize);
105 tasks.schedule([start, next, f]() {
106 auto recurseInfo = detail::PerPoolPerThreadInfo::parForRecurse();
107 for (Iter it = start; it != next; ++it) {
115 std::advance(end, chunkSize);
118 for (Iter it = start; it != end; ++it) {
125 auto recurseInfo = detail::PerPoolPerThreadInfo::parForRecurse();
126 for (Iter it = start; it != end; ++it) {